Search in sources :

Example 31 with XmallException

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

Example 32 with XmallException

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

Example 33 with XmallException

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

Example 34 with XmallException

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

Example 35 with XmallException

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

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