Search in sources :

Example 1 with TbMember

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

Example 2 with TbMember

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

Example 3 with TbMember

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;
}
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 4 with TbMember

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;
}
Also used : TbMember(cn.exrick.manager.pojo.TbMember) Gson(com.google.gson.Gson) XmallException(cn.exrick.common.exception.XmallException) TbMember(cn.exrick.manager.pojo.TbMember) Member(cn.exrick.manager.dto.front.Member)

Example 5 with TbMember

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

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