com.macro.mall.model.UmsMember Java Examples

The following examples show how to use com.macro.mall.model.UmsMember. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UmsMemberServiceImpl.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
@Override
public CommonResult updatePassword(String telephone, String password, String authCode) {
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andPhoneEqualTo(telephone);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if(CollectionUtils.isEmpty(memberList)){
        return CommonResult.failed("该账号不存在");
    }
    //验证验证码
    if(!verifyAuthCode(authCode,telephone)){
        return CommonResult.failed("验证码错误");
    }
    UmsMember umsMember = memberList.get(0);
    umsMember.setPassword(passwordEncoder.encode(password));
    memberMapper.updateByPrimaryKeySelective(umsMember);
    return CommonResult.success(null,"密码修改成功");
}
 
Example #2
Source File: OmsCartItemServiceImpl.java    From mall with Apache License 2.0 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #3
Source File: OmsCartItemServiceImpl.java    From macrozheng-mall with MIT License 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #4
Source File: UmsMemberServiceImpl.java    From mall with Apache License 2.0 6 votes vote down vote up
@Override
public void updatePassword(String telephone, String password, String authCode) {
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andPhoneEqualTo(telephone);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if(CollectionUtils.isEmpty(memberList)){
        Asserts.fail("该账号不存在");
    }
    //验证验证码
    if(!verifyAuthCode(authCode,telephone)){
        Asserts.fail("验证码错误");
    }
    UmsMember umsMember = memberList.get(0);
    umsMember.setPassword(passwordEncoder.encode(password));
    memberMapper.updateByPrimaryKeySelective(umsMember);
    memberCacheService.delMember(umsMember.getId());
}
 
Example #5
Source File: UmsMemberServiceImpl.java    From macrozheng-mall with MIT License 6 votes vote down vote up
@Override
public CommonResult updatePassword(String telephone, String password, String authCode) {
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andPhoneEqualTo(telephone);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if(CollectionUtils.isEmpty(memberList)){
        return new CommonResult().failed("该账号不存在");
    }
    //验证验证码
    if(!verifyAuthCode(authCode,telephone)){
        return new CommonResult().failed("验证码错误");
    }
    UmsMember umsMember = memberList.get(0);
    umsMember.setPassword(passwordEncoder.encodePassword(password,null));
    memberMapper.updateByPrimaryKeySelective(umsMember);
    return new CommonResult().success("密码修改成功",null);
}
 
Example #6
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #7
Source File: UmsMemberServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public void updateIntegration(Long id, Integer integration) {
    UmsMember record=new UmsMember();
    record.setId(id);
    record.setIntegration(integration);
    memberMapper.updateByPrimaryKeySelective(record);
    memberCacheService.delMember(id);
}
 
Example #8
Source File: UmsMemberCacheServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public void delMember(Long memberId) {
    UmsMember umsMember = memberMapper.selectByPrimaryKey(memberId);
    if (umsMember != null) {
        String key = REDIS_DATABASE + ":" + REDIS_KEY_MEMBER + ":" + umsMember.getUsername();
        redisService.del(key);
    }
}
 
Example #9
Source File: UmsMemberReceiveAddressServiceImpl.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMemberReceiveAddress getItem(Long id) {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    List<UmsMemberReceiveAddress> addressList = addressMapper.selectByExample(example);
    if(!CollectionUtils.isEmpty(addressList)){
        return addressList.get(0);
    }
    return null;
}
 
Example #10
Source File: UmsMemberServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public CommonResult register(String username, String password, String telephone, String authCode) {
    //验证验证码
    if(!verifyAuthCode(authCode,telephone)){
        return new CommonResult().failed("验证码错误");
    }
    //查询是否已有该用户
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andUsernameEqualTo(username);
    example.or(example.createCriteria().andPhoneEqualTo(telephone));
    List<UmsMember> umsMembers = memberMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(umsMembers)) {
        return new CommonResult().failed("该用户已经存在");
    }
    //没有该用户进行添加操作
    UmsMember umsMember = new UmsMember();
    umsMember.setUsername(username);
    umsMember.setPhone(telephone);
    umsMember.setPassword(passwordEncoder.encodePassword(password, null));
    umsMember.setCreateTime(new Date());
    umsMember.setStatus(1);
    //获取默认会员等级并设置
    UmsMemberLevelExample levelExample = new UmsMemberLevelExample();
    levelExample.createCriteria().andDefaultStatusEqualTo(1);
    List<UmsMemberLevel> memberLevelList = memberLevelMapper.selectByExample(levelExample);
    if (!CollectionUtils.isEmpty(memberLevelList)) {
        umsMember.setMemberLevelId(memberLevelList.get(0).getId());
    }
    memberMapper.insert(umsMember);
    umsMember.setPassword(null);
    return new CommonResult().success("注册成功",null);
}
 
Example #11
Source File: UmsMemberReceiveAddressServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMemberReceiveAddress getItem(Long id) {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    List<UmsMemberReceiveAddress> addressList = addressMapper.selectByExample(example);
    if(!CollectionUtils.isEmpty(addressList)){
        return addressList.get(0);
    }
    return null;
}
 
Example #12
Source File: UmsMemberServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public UserDetails loadUserByUsername(String username) {
    UmsMember member = getByUsername(username);
    if(member!=null){
        return new MemberDetails(member);
    }
    throw new UsernameNotFoundException("用户名或密码错误");
}
 
Example #13
Source File: UmsMemberServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public void updateIntegration(Long id, Integer integration) {
    UmsMember record=new UmsMember();
    record.setId(id);
    record.setIntegration(integration);
    memberMapper.updateByPrimaryKeySelective(record);
}
 
Example #14
Source File: UmsMemberReceiveAddressServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public List<UmsMemberReceiveAddress> list() {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId());
    return addressMapper.selectByExample(example);
}
 
Example #15
Source File: UmsMemberServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMember getCurrentMember() {
    SecurityContext ctx = SecurityContextHolder.getContext();
    Authentication auth = ctx.getAuthentication();
    MemberDetails memberDetails = (MemberDetails) auth.getPrincipal();
    return memberDetails.getUmsMember();
}
 
Example #16
Source File: UmsMemberServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMember getByUsername(String username) {
    UmsMember member = memberCacheService.getMember(username);
    if(member!=null) return member;
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andUsernameEqualTo(username);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(memberList)) {
        member = memberList.get(0);
        memberCacheService.setMember(member);
        return member;
    }
    return null;
}
 
Example #17
Source File: UmsMemberServiceImpl.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMember getByUsername(String username) {
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andUsernameEqualTo(username);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(memberList)) {
        return memberList.get(0);
    }
    return null;
}
 
Example #18
Source File: UmsMemberServiceImpl.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public void updateIntegration(Long id, Integer integration) {
    UmsMember record=new UmsMember();
    record.setId(id);
    record.setIntegration(integration);
    memberMapper.updateByPrimaryKeySelective(record);
}
 
Example #19
Source File: MemberCollectionServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public int add(MemberProductCollection productCollection) {
    int count = 0;
    UmsMember member = memberService.getCurrentMember();
    productCollection.setMemberId(member.getId());
    productCollection.setMemberNickname(member.getNickname());
    productCollection.setMemberIcon(member.getIcon());
    MemberProductCollection findCollection = productCollectionRepository.findByMemberIdAndProductId(productCollection.getMemberId(), productCollection.getProductId());
    if (findCollection == null) {
        productCollectionRepository.save(productCollection);
        count = 1;
    }
    return count;
}
 
Example #20
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public int update(Long id, UmsMemberReceiveAddress address) {
    address.setId(null);
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    return addressMapper.updateByExampleSelective(address,example);
}
 
Example #21
Source File: UmsMemberReceiveAddressServiceImpl.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
@Override
public List<UmsMemberReceiveAddress> list() {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId());
    return addressMapper.selectByExample(example);
}
 
Example #22
Source File: MemberReadHistoryServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public int create(MemberReadHistory memberReadHistory) {
    UmsMember member = memberService.getCurrentMember();
    memberReadHistory.setMemberId(member.getId());
    memberReadHistory.setMemberNickname(member.getNickname());
    memberReadHistory.setMemberIcon(member.getIcon());
    memberReadHistory.setId(null);
    memberReadHistory.setCreateTime(new Date());
    memberReadHistoryRepository.save(memberReadHistory);
    return 1;
}
 
Example #23
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMemberReceiveAddress getItem(Long id) {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    List<UmsMemberReceiveAddress> addressList = addressMapper.selectByExample(example);
    if(!CollectionUtils.isEmpty(addressList)){
        return addressList.get(0);
    }
    return null;
}
 
Example #24
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public List<UmsMemberReceiveAddress> list() {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId());
    return addressMapper.selectByExample(example);
}
 
Example #25
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public int update(Long id, UmsMemberReceiveAddress address) {
    address.setId(null);
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    return addressMapper.updateByExampleSelective(address,example);
}
 
Example #26
Source File: UmsMemberServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMember getByUsername(String username) {
    UmsMemberExample example = new UmsMemberExample();
    example.createCriteria().andUsernameEqualTo(username);
    List<UmsMember> memberList = memberMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(memberList)) {
        return memberList.get(0);
    }
    return null;
}
 
Example #27
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public int delete(Long id) {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId()).andIdEqualTo(id);
    return addressMapper.deleteByExample(example);
}
 
Example #28
Source File: UmsMemberReceiveAddressServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public List<UmsMemberReceiveAddress> list() {
    UmsMember currentMember = memberService.getCurrentMember();
    UmsMemberReceiveAddressExample example = new UmsMemberReceiveAddressExample();
    example.createCriteria().andMemberIdEqualTo(currentMember.getId());
    return addressMapper.selectByExample(example);
}
 
Example #29
Source File: UmsMemberServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public UmsMember getCurrentMember() {
    SecurityContext ctx = SecurityContextHolder.getContext();
    Authentication auth = ctx.getAuthentication();
    MemberDetails memberDetails = (MemberDetails) auth.getPrincipal();
    return memberDetails.getUmsMember();
}
 
Example #30
Source File: UmsMemberServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public void updateIntegration(Long id, Integer integration) {
    UmsMember record=new UmsMember();
    record.setId(id);
    record.setIntegration(integration);
    memberMapper.updateByPrimaryKeySelective(record);
}