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