use of com.whoiszxl.entity.MemberInfo in project shopzz by whoiszxl.
the class MemberServiceImpl method passwordRegister.
@Override
public boolean passwordRegister(String username, String password) {
long memberId = idWorker.nextId();
Member member = new Member();
member.setId(memberId);
member.setUsername(username);
member.setPhone(username);
member.setPassword(passwordEncoder.encode(password));
this.save(member);
MemberInfo memberInfo = new MemberInfo();
memberInfo.setMemberId(memberId);
memberInfoService.save(memberInfo);
return true;
}
use of com.whoiszxl.entity.MemberInfo in project shopzz by whoiszxl.
the class MemberController method updateMemberInfo.
@SaCheckLogin
@PutMapping
@Transactional
@ApiOperation(value = "更新当前登录用户的详细信息", notes = "更新当前登录用户的详细信息", response = Boolean.class)
public ResponseResult<Boolean> updateMemberInfo(@RequestBody MemberDetailVO memberDetailVO) {
long memberId = StpUtil.getLoginIdAsLong();
// 1. 更新用户信息
MemberVO memberVO = memberDetailVO.getMember();
Member member = dozerUtils.map(memberVO, Member.class);
member.setId(memberId);
memberService.updateById(member);
// 2. 更新用户详细信息
MemberInfoVO memberInfoVO = memberDetailVO.getMemberInfo();
MemberInfo memberInfo = dozerUtils.map(memberInfoVO, MemberInfo.class);
memberInfo.setMemberId(memberId);
memberInfoService.updateByMemberId(memberInfo);
return ResponseResult.buildSuccess();
}
use of com.whoiszxl.entity.MemberInfo in project shopzz by whoiszxl.
the class MemberController method login.
@Transactional
@PostMapping("/login")
@ApiOperation(value = "账号密码登录", notes = "账号密码登录", response = ResponseResult.class)
public ResponseResult<String> login(@RequestBody LoginQuery loginQuery) {
// 1. 从数据库查询用户名和密码是否匹配
Member member = memberService.getOne(new QueryWrapper<Member>().eq("username", loginQuery.getUsername()));
if (member == null || !passwordEncoder.matches(loginQuery.getPassword(), member.getPassword())) {
return ResponseResult.buildError("账号或密码错误");
}
// 2. 登录并获取token
StpUtil.login(member.getId());
// 3. 更新最后登录时间
MemberInfo memberInfo = new MemberInfo();
memberInfo.setMemberId(member.getId());
memberInfo.setLastLogin(new Date());
memberInfoService.updateByMemberId(memberInfo);
return ResponseResult.buildSuccess("登录成功", StpUtil.getTokenValue());
}
use of com.whoiszxl.entity.MemberInfo in project shopzz by whoiszxl.
the class MemberServiceImpl method memberInfo.
@Override
public MemberDetailVO memberInfo() {
// 1. 获取到当前登录用户的ID
long memberId = StpUtil.getLoginIdAsLong();
// 2. 分别从会员、会员信息表中查询出
Member member = this.getById(memberId);
MemberVO memberVO = dozerUtils.map(member, MemberVO.class);
MemberInfo memberInfo = memberInfoService.getByMemberId(memberId);
MemberInfoVO memberInfoVO = dozerUtils.map(memberInfo, MemberInfoVO.class);
MemberDetailVO memberDetailVO = new MemberDetailVO();
memberDetailVO.setMemberInfo(memberInfoVO);
memberDetailVO.setMember(memberVO);
return memberDetailVO;
}
Aggregations