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