use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method addMember.
@Override
public TbMember addMember(MemberDto memberDto) {
TbMember tbMember = DtoUtil.MemberDto2Member(memberDto);
if (getMemberByUsername(tbMember.getUsername()) != null) {
throw new XmallException("用户名已被注册");
}
if (getMemberByPhone(tbMember.getPhone()) != null) {
throw new XmallException("手机号已被注册");
}
if (getMemberByEmail(tbMember.getEmail()) != null) {
throw new XmallException("邮箱已被注册");
}
tbMember.setState(1);
tbMember.setCreated(new Date());
tbMember.setUpdated(new Date());
String md5Pass = DigestUtils.md5DigestAsHex(tbMember.getPassword().getBytes());
tbMember.setPassword(md5Pass);
if (tbMemberMapper.insert(tbMember) != 1) {
throw new XmallException("添加用户失败");
}
return getMemberByPhone(tbMember.getPhone());
}
use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method getMemberById.
@Override
public TbMember getMemberById(long memberId) {
TbMember tbMember;
try {
tbMember = tbMemberMapper.selectByPrimaryKey(memberId);
} catch (Exception e) {
throw new XmallException("ID获取会员信息失败");
}
tbMember.setPassword("");
return tbMember;
}
use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method updateMember.
@Override
public TbMember updateMember(Long id, MemberDto memberDto) {
TbMember tbMember = DtoUtil.MemberDto2Member(memberDto);
tbMember.setId(id);
tbMember.setUpdated(new Date());
TbMember oldMember = getMemberById(id);
tbMember.setState(oldMember.getState());
tbMember.setCreated(oldMember.getCreated());
if (tbMember.getPassword() == null || tbMember.getPassword() == "") {
tbMember.setPassword(oldMember.getPassword());
} else {
String md5Pass = DigestUtils.md5DigestAsHex(tbMember.getPassword().getBytes());
tbMember.setPassword(md5Pass);
}
if (tbMemberMapper.updateByPrimaryKey(tbMember) != 1) {
throw new XmallException("更新会员信息失败");
}
return getMemberById(id);
}
use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method changePassMember.
@Override
public TbMember changePassMember(Long id, MemberDto memberDto) {
TbMember tbMember = tbMemberMapper.selectByPrimaryKey(id);
String md5Pass = DigestUtils.md5DigestAsHex(memberDto.getPassword().getBytes());
tbMember.setPassword(md5Pass);
tbMember.setUpdated(new Date());
if (tbMemberMapper.updateByPrimaryKey(tbMember) != 1) {
throw new XmallException("修改会员密码失败");
}
return getMemberById(id);
}
use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method getMemberByEmail.
@Override
public TbMember getMemberByEmail(String email) {
List<TbMember> list;
TbMemberExample example = new TbMemberExample();
TbMemberExample.Criteria criteria = example.createCriteria();
criteria.andEmailEqualTo(email);
try {
list = tbMemberMapper.selectByExample(example);
} catch (Exception e) {
throw new XmallException("Email获取会员信息失败");
}
if (!list.isEmpty()) {
list.get(0).setPassword("");
return list.get(0);
}
return null;
}
Aggregations