use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method getMemberList.
@Override
public DataTablesResult getMemberList(int draw, int start, int length, String search, String minDate, String maxDate, String orderCol, String orderDir) {
DataTablesResult result = new DataTablesResult();
try {
// 分页
PageHelper.startPage(start / length + 1, length);
List<TbMember> list = tbMemberMapper.selectByMemberInfo("%" + search + "%", minDate, maxDate, orderCol, orderDir);
PageInfo<TbMember> pageInfo = new PageInfo<>(list);
for (TbMember tbMember : list) {
tbMember.setPassword("");
}
result.setRecordsFiltered((int) pageInfo.getTotal());
result.setRecordsTotal(getMemberCount().getRecordsTotal());
result.setDraw(draw);
result.setData(list);
} catch (Exception e) {
throw new XmallException("加载用户列表失败");
}
return result;
}
use of cn.exrick.manager.pojo.TbMember in project xmall by Exrick.
the class MemberServiceImpl method alertMemberState.
@Override
public TbMember alertMemberState(Long id, Integer state) {
TbMember tbMember = tbMemberMapper.selectByPrimaryKey(id);
tbMember.setState(state);
tbMember.setUpdated(new Date());
if (tbMemberMapper.updateByPrimaryKey(tbMember) != 1) {
throw new XmallException("修改会员状态失败");
}
return getMemberById(id);
}
use of cn.exrick.manager.pojo.TbMember 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.TbMember in project xmall by Exrick.
the class MemberServiceImpl method imageUpload.
@Override
public String imageUpload(Long userId, String token, String imgData) {
// 过滤data:URL
String base64 = QiniuUtil.base64Data(imgData);
String imgPath = QiniuUtil.qiniuBase64Upload(base64);
TbMember tbMember = tbMemberMapper.selectByPrimaryKey(userId);
if (tbMember == null) {
throw new XmallException("通过id获取用户失败");
}
tbMember.setFile(imgPath);
if (tbMemberMapper.updateByPrimaryKey(tbMember) != 1) {
throw new XmallException("更新用户头像失败");
}
// 更新缓存
Member member = loginService.getUserByToken(token);
member.setFile(imgPath);
jedisClient.set("SESSION:" + token, new Gson().toJson(member));
return imgPath;
}
use of cn.exrick.manager.pojo.TbMember 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;
}
Aggregations