✨ Feat: [后台]:新增获取当前用户基本信息接口
This commit is contained in:
parent
c39bc7922c
commit
d26ffa1dd4
@ -4,6 +4,7 @@ import com.fanxb.bookmark.business.user.entity.LoginBody;
|
|||||||
import com.fanxb.bookmark.business.user.entity.RegisterBody;
|
import com.fanxb.bookmark.business.user.entity.RegisterBody;
|
||||||
import com.fanxb.bookmark.business.user.service.UserService;
|
import com.fanxb.bookmark.business.user.service.UserService;
|
||||||
import com.fanxb.bookmark.common.entity.Result;
|
import com.fanxb.bookmark.common.entity.Result;
|
||||||
|
import com.fanxb.bookmark.common.util.UserContextHolder;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -50,6 +51,18 @@ public class UserController {
|
|||||||
return Result.success(null);
|
return Result.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 获取当前登录用户的基本信息
|
||||||
|
*
|
||||||
|
* @return com.fanxb.bookmark.common.entity.Result
|
||||||
|
* @author fanxb
|
||||||
|
* @date 2019/7/30 15:14
|
||||||
|
*/
|
||||||
|
@GetMapping("/currentUserInfo")
|
||||||
|
public Result currentUserInfo() {
|
||||||
|
return Result.success(userService.getUserInfo(UserContextHolder.get().getUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description: 用户登录
|
* Description: 用户登录
|
||||||
*
|
*
|
||||||
|
@ -53,4 +53,14 @@ public interface UserDao {
|
|||||||
* @date 2019/7/9 20:03
|
* @date 2019/7/9 20:03
|
||||||
*/
|
*/
|
||||||
void resetPassword(@Param("password") String password,@Param("email") String email);
|
void resetPassword(@Param("password") String password,@Param("email") String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 根据用户id查询用户信息
|
||||||
|
*
|
||||||
|
* @author fanxb
|
||||||
|
* @date 2019/7/30 16:08
|
||||||
|
* @param userId userId
|
||||||
|
* @return com.fanxb.bookmark.common.entity.User
|
||||||
|
*/
|
||||||
|
User selectByUserId(int userId);
|
||||||
}
|
}
|
||||||
|
@ -144,4 +144,16 @@ public class UserService {
|
|||||||
String newPassword = HashUtil.sha1(HashUtil.md5(body.getPassword()));
|
String newPassword = HashUtil.sha1(HashUtil.md5(body.getPassword()));
|
||||||
userDao.resetPassword(newPassword, body.getEmail());
|
userDao.resetPassword(newPassword, body.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: 根据userId获取用户信息
|
||||||
|
*
|
||||||
|
* @author fanxb
|
||||||
|
* @date 2019/7/30 15:57
|
||||||
|
* @param userId userId
|
||||||
|
* @return com.fanxb.bookmark.common.entity.User
|
||||||
|
*/
|
||||||
|
public User getUserInfo(int userId){
|
||||||
|
return userDao.selectByUserId(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,5 +34,15 @@
|
|||||||
where email = #{email}
|
where email = #{email}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByUserId" resultType="com.fanxb.bookmark.common.entity.User">
|
||||||
|
select
|
||||||
|
userId,
|
||||||
|
username,
|
||||||
|
email,
|
||||||
|
icon
|
||||||
|
from user
|
||||||
|
where userId = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
x
Reference in New Issue
Block a user