Search in sources :

Example 1 with TbMemberExample

use of cn.exrick.manager.pojo.TbMemberExample in project xmall by Exrick.

the class LoginServiceImpl method userLogin.

@Override
public Member userLogin(String username, String password) {
    TbMemberExample example = new TbMemberExample();
    TbMemberExample.Criteria criteria = example.createCriteria();
    criteria.andStateEqualTo(1);
    criteria.andUsernameEqualTo(username);
    List<TbMember> list = tbMemberMapper.selectByExample(example);
    if (list == null || list.size() == 0) {
        Member member = new Member();
        member.setState(0);
        member.setMessage("用户名或密码错误");
        return member;
    }
    TbMember tbMember = list.get(0);
    // md5加密
    if (!DigestUtils.md5DigestAsHex(password.getBytes()).equals(tbMember.getPassword())) {
        Member member = new Member();
        member.setState(0);
        member.setMessage("用户名或密码错误");
        return member;
    }
    String token = UUID.randomUUID().toString();
    Member member = DtoUtil.TbMemer2Member(tbMember);
    member.setToken(token);
    member.setState(1);
    // 用户信息写入redis:key:"SESSION:token" value:"user"
    jedisClient.set("SESSION:" + token, new Gson().toJson(member));
    jedisClient.expire("SESSION:" + token, SESSION_EXPIRE);
    return member;
}
Also used : TbMemberExample(cn.exrick.manager.pojo.TbMemberExample) TbMember(cn.exrick.manager.pojo.TbMember) Gson(com.google.gson.Gson) TbMember(cn.exrick.manager.pojo.TbMember) Member(cn.exrick.manager.dto.front.Member)

Example 2 with TbMemberExample

use of cn.exrick.manager.pojo.TbMemberExample in project xmall by Exrick.

the class RegisterServiceImpl method checkData.

@Override
public boolean checkData(String param, int type) {
    TbMemberExample example = new TbMemberExample();
    TbMemberExample.Criteria criteria = example.createCriteria();
    criteria.andStateEqualTo(1);
    // 1:用户名 2:手机号 3:邮箱
    if (type == 1) {
        criteria.andUsernameEqualTo(param);
    } else if (type == 2) {
        criteria.andPhoneEqualTo(param);
    } else if (type == 3) {
        criteria.andEmailEqualTo(param);
    } else {
        return false;
    }
    List<TbMember> list = tbMemberMapper.selectByExample(example);
    if (list != null && list.size() > 0) {
        return false;
    }
    return true;
}
Also used : TbMemberExample(cn.exrick.manager.pojo.TbMemberExample) TbMember(cn.exrick.manager.pojo.TbMember)

Example 3 with TbMemberExample

use of cn.exrick.manager.pojo.TbMemberExample 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;
}
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)

Example 4 with TbMemberExample

use of cn.exrick.manager.pojo.TbMemberExample in project xmall by Exrick.

the class MemberServiceImpl method getMemberByPhone.

@Override
public TbMember getMemberByPhone(String phone) {
    List<TbMember> list;
    TbMemberExample example = new TbMemberExample();
    TbMemberExample.Criteria criteria = example.createCriteria();
    criteria.andPhoneEqualTo(phone);
    try {
        list = tbMemberMapper.selectByExample(example);
    } catch (Exception e) {
        throw new XmallException("Phone获取会员信息失败");
    }
    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)

Example 5 with TbMemberExample

use of cn.exrick.manager.pojo.TbMemberExample 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)

Aggregations

TbMemberExample (cn.exrick.manager.pojo.TbMemberExample)7 XmallException (cn.exrick.common.exception.XmallException)5 TbMember (cn.exrick.manager.pojo.TbMember)5 DataTablesResult (cn.exrick.common.pojo.DataTablesResult)2 Member (cn.exrick.manager.dto.front.Member)1 Gson (com.google.gson.Gson)1