use of cn.exrick.common.exception.XmallException in project xmall by Exrick.
the class MemberServiceImpl method getRemoveMemberCount.
@Override
public DataTablesResult getRemoveMemberCount() {
DataTablesResult result = new DataTablesResult();
TbMemberExample example = new TbMemberExample();
TbMemberExample.Criteria criteria = example.createCriteria();
criteria.andStateEqualTo(2);
try {
result.setRecordsTotal((int) tbMemberMapper.countByExample(example));
} catch (Exception e) {
throw new XmallException("统计移除会员数失败");
}
return result;
}
use of cn.exrick.common.exception.XmallException 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.common.exception.XmallException in project xmall by Exrick.
the class MemberServiceImpl method getMemberCount.
@Override
public DataTablesResult getMemberCount() {
DataTablesResult result = new DataTablesResult();
TbMemberExample example = new TbMemberExample();
TbMemberExample.Criteria criteria = example.createCriteria();
criteria.andStateNotEqualTo(2);
try {
result.setRecordsTotal((int) tbMemberMapper.countByExample(example));
} catch (Exception e) {
throw new XmallException("统计会员数失败");
}
return result;
}
use of cn.exrick.common.exception.XmallException 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.common.exception.XmallException 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);
}
Aggregations