用户找回密码
This commit is contained in:
parent
ce05d3e5cd
commit
b20b33ee53
@ -66,7 +66,7 @@ public class UserController {
|
|||||||
map.put("msg","验证码错误");
|
map.put("msg","验证码错误");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
map.put("code",0);
|
|
||||||
if(StringUtils.isEmpty(user.getUserLogin())||StringUtils.isEmpty(user.getUserPassword())){
|
if(StringUtils.isEmpty(user.getUserLogin())||StringUtils.isEmpty(user.getUserPassword())){
|
||||||
map.put("msg","用户或密码为空!");
|
map.put("msg","用户或密码为空!");
|
||||||
return map;
|
return map;
|
||||||
@ -75,10 +75,16 @@ public class UserController {
|
|||||||
User user1 = userService.userLogin(user);
|
User user1 = userService.userLogin(user);
|
||||||
|
|
||||||
if(user1!=null){
|
if(user1!=null){
|
||||||
|
map.put("code",200);
|
||||||
String token= tokenUtils.sign(user1);
|
String token= tokenUtils.sign(user1);
|
||||||
map.put("cod",1);
|
map.put("userEmail",user1.getUserEmail());
|
||||||
map.put("data",user1);
|
map.put("userLogin",user1.getUserLogin());
|
||||||
|
map.put("user",user1.getUserEmail());
|
||||||
|
map.put("userStatus",user1.getUserStatus());
|
||||||
|
map.put("Id",user1.getId());
|
||||||
|
map.put("nickname",user1.getNickname());
|
||||||
|
map.put("roleId",user1.getRoleId());
|
||||||
|
map.put("userRegistered",user1.getUserRegistered());
|
||||||
map.put("token",token);
|
map.put("token",token);
|
||||||
}else {
|
}else {
|
||||||
map.put("msg","用户名或密码错误!");
|
map.put("msg","用户名或密码错误!");
|
||||||
@ -99,6 +105,36 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@RequestMapping("/findThePassword")
|
||||||
|
public Map<String,Object> findThePassword(User user,HttpSession session){
|
||||||
|
Map<String,Object> map=new HashMap<>();
|
||||||
|
User user1=userService.selectUserAlreadyExist(user);
|
||||||
|
if (user1==null){
|
||||||
|
map.put("msg","无此邮箱");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
// 比较验证码
|
||||||
|
// if (!user.getActiveCode().equals((String) session.getAttribute(user.getUserEmail()))) {
|
||||||
|
// map.put("msg","验证码不正确") ;
|
||||||
|
// return map;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if (user1 != null) {
|
||||||
|
int result=userService.updatePassword(user1);
|
||||||
|
if(result==1){
|
||||||
|
map.put("Data",user1.getUserLogin());
|
||||||
|
map.put("Data",user1.getUserEmail());
|
||||||
|
map.put("msg","重置成功");
|
||||||
|
return map;
|
||||||
|
}else {
|
||||||
|
map.put("msg","重置失败");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return map;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,6 @@ public interface UserDao {
|
|||||||
|
|
||||||
User selectByUserLogin(String user_Login);
|
User selectByUserLogin(String user_Login);
|
||||||
|
|
||||||
|
int updateByEmail(User user);
|
||||||
|
|
||||||
}
|
}
|
@ -13,4 +13,6 @@ public interface UserService {
|
|||||||
|
|
||||||
public User userLogin(User user);
|
public User userLogin(User user);
|
||||||
|
|
||||||
|
public int updatePassword(User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import com.lovenav.utils.MD5Utils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
@ -23,9 +25,15 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int UserRegister(User user) {
|
public int UserRegister(User user) {
|
||||||
|
|
||||||
user.setRoleId(Byte.valueOf("1"));
|
user.setRoleId(Byte.valueOf("1"));
|
||||||
user.setUserStatus(Byte.valueOf("1"));
|
user.setUserStatus(Byte.valueOf("1"));
|
||||||
user.setUserPassword(MD5Utils.md5(user.getUserPassword()));
|
user.setUserPassword(MD5Utils.md5(user.getUserPassword()));
|
||||||
|
Date date=new Date();
|
||||||
|
user.setUserRegistered(date);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return userDao.insert(user);
|
return userDao.insert(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,5 +75,11 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updatePassword(User user) {
|
||||||
|
user.setUserPassword(MD5Utils.md5(user.getUserPassword()));
|
||||||
|
return userDao.updateByEmail(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,39 @@
|
|||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateByEmail" parameterType="com.lovenav.entity.User">
|
||||||
|
update ln_user
|
||||||
|
<set>
|
||||||
|
<if test="userLogin != null">
|
||||||
|
user_login = #{userLogin,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="userPassword != null">
|
||||||
|
user_password = #{userPassword,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="phone != null">
|
||||||
|
phone = #{phone,jdbcType=BIGINT},
|
||||||
|
</if>
|
||||||
|
<if test="avatar != null">
|
||||||
|
avatar = #{avatar,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="nickname != null">
|
||||||
|
nickname = #{nickname,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="userEmail != null">
|
||||||
|
user_email = #{userEmail,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="userStatus != null">
|
||||||
|
user_status = #{userStatus,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
<if test="userRegistered != null">
|
||||||
|
user_registered = #{userRegistered,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
<if test="roleId != null">
|
||||||
|
role_id = #{roleId,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where user_email = #{userEmail,jdbcType=VARCHAR}
|
||||||
|
</update>
|
||||||
<select id="selectByEmail" parameterType="java.lang.String" resultMap="BaseResultMap">
|
<select id="selectByEmail" parameterType="java.lang.String" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
|
Loading…
Reference in New Issue
Block a user