注册流程图

用户注册 v1 -根据邮箱注册用户_java

 

1. 验证邮箱有效性(代码亲测有效)

public static boolean verifyEmail(String email) {
Pattern regex = Pattern.compile("^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
return regex.matcher(email).matches();
}

邮箱正则表达式解析

2. 验证邮箱是否存在

<select id="selectUserByEmail" resultType="java.lang.Integer">
SELECT count(*) FROM user WHERE email = #{email};
</select>

3. 插入数据

<insert id="insertUserByEmail" parameterType="User">
INSERT INTO user
(email)
VALUES
(#{email});
</insert>