Commit 6291581a by zhoujinghao

app用户注册登陆接口提交

1 parent a72d87a1
...@@ -20,7 +20,7 @@ import java.util.List; ...@@ -20,7 +20,7 @@ import java.util.List;
@Mapper @Mapper
public interface AppUserMapper extends BaseMapper<AppUserPO> { public interface AppUserMapper extends BaseMapper<AppUserPO> {
List<UserVO> selectByPassword(LoginDto loginDto); UserVO selectByPassword(LoginDto loginDto);
List<UserVO> selectByPhone(@Param("phone") String phone); UserVO selectByPhone(@Param("phone") String phone);
} }
...@@ -77,6 +77,11 @@ public class UserServiceImpl implements UserService { ...@@ -77,6 +77,11 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public ApiResponse register(RegisterDto registerDto) { public ApiResponse register(RegisterDto registerDto) {
//查询用户信息通过手机号
UserVO userVO = appUserMapper.selectByPhone(registerDto.getPhone());
if (null != userVO){
throw new BusinessException("该用户已注册");
}
//用户实体类 //用户实体类
AppUserPO appUser = new AppUserPO(); AppUserPO appUser = new AppUserPO();
appUser.setId(SnowFlakeUtil.nextId()); appUser.setId(SnowFlakeUtil.nextId());
...@@ -90,12 +95,8 @@ public class UserServiceImpl implements UserService { ...@@ -90,12 +95,8 @@ public class UserServiceImpl implements UserService {
throw new BusinessException("两次密码输入不相同,请再次输入"); throw new BusinessException("两次密码输入不相同,请再次输入");
} }
appUser.setLoginPwd(registerDto.getLoginPwd()); appUser.setLoginPwd(registerDto.getLoginPwd());
//格式化格式 appUser.setCreateTime(LocalDateTime.now());
String format = "YYYY-MM-dd hh:mm:ss"; appUser.setUpdateTime(LocalDateTime.now());
// DateTimeFormatter.ofPattern方法根据指定的格式输出时间
String formatDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern(format));
// appUser.setCreateTime(formatDateTime);
// appUser.setUpdateTime(new Date());
log.info("用户注册参数==============>"+registerDto); log.info("用户注册参数==============>"+registerDto);
//将验证码放入到缓存当中(过期时间60s)test //将验证码放入到缓存当中(过期时间60s)test
// GuavaUtil.putTrackGuava(registerDto.getPhone(),registerDto.getCode()); // GuavaUtil.putTrackGuava(registerDto.getPhone(),registerDto.getCode());
...@@ -123,12 +124,12 @@ public class UserServiceImpl implements UserService { ...@@ -123,12 +124,12 @@ public class UserServiceImpl implements UserService {
*/ */
@Override @Override
public ApiResponse<UserVO> userLogin(LoginDto loginDto) { public ApiResponse<UserVO> userLogin(LoginDto loginDto) {
List<UserVO> userVo = new ArrayList<>(); UserVO userVo = new UserVO();
//首先判断登陆方式 //首先判断登陆方式
if (loginDto.getType().equals("0")){ if (loginDto.getType().equals("0")){
//密码登陆 //密码登陆
userVo = appUserMapper.selectByPassword(loginDto); userVo = appUserMapper.selectByPassword(loginDto);
if (userVo.isEmpty()){ if (null != userVo){
throw new BusinessException("请先注册"); throw new BusinessException("请先注册");
} }
}else{ }else{
...@@ -142,7 +143,7 @@ public class UserServiceImpl implements UserService { ...@@ -142,7 +143,7 @@ public class UserServiceImpl implements UserService {
throw new BusinessException("验证码错误请重新输入"); throw new BusinessException("验证码错误请重新输入");
} }
userVo = appUserMapper.selectByPhone(loginDto.getPhone()); userVo = appUserMapper.selectByPhone(loginDto.getPhone());
if (userVo.isEmpty()){ if (null != userVo){
throw new BusinessException("请先注册"); throw new BusinessException("请先注册");
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!