1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-09-13 23:41:39 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

手机号重复注册验证

This commit is contained in:
2022-03-02 11:36:06 +08:00
parent a02d930f11
commit 7dcb922041
2 changed files with 13 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import com.cxyxiaomo.flashsale.service.model.UserModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -50,7 +51,11 @@ public class UserServiceImpl implements UserService {
// 实现 model -> dataobject 方法
UserDO userDO = convertFormModel(userModel);
userDOMapper.insertSelective(userDO);
try {
userDOMapper.insertSelective(userDO);
} catch (DuplicateKeyException ex) {
throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR, "手机号已被注册");
}
userModel.setId(userDO.getId());