Search in sources :

Example 11 with TbMember

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

Example 12 with TbMember

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;
}
Also used : TbMember(cn.exrick.manager.pojo.TbMember) XmallException(cn.exrick.common.exception.XmallException) XmallException(cn.exrick.common.exception.XmallException)

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

Example 14 with TbMember

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

Example 15 with TbMember

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

TbMember (cn.exrick.manager.pojo.TbMember)17 XmallException (cn.exrick.common.exception.XmallException)12 TbMemberExample (cn.exrick.manager.pojo.TbMemberExample)5 Date (java.util.Date)5 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)2 Member (cn.exrick.manager.dto.front.Member)2 PageInfo (com.github.pagehelper.PageInfo)2 Gson (com.google.gson.Gson)2