♻️ 个人中心路径 /user/nickname -> /user/account

This commit is contained in:
ronger 2021-03-26 10:46:21 +08:00
parent f9528399bf
commit 13edb5a063
12 changed files with 46 additions and 39 deletions

View File

@ -191,7 +191,7 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.15</version>
<version>1.4.16</version>
</dependency>
<dependency>
<groupId>com.github.jedis-lock</groupId>

View File

@ -45,7 +45,7 @@ public class MybatisConfigurer {
//添加XML目录
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
factory.setMapperLocations(resolver.getResources("classpath:mapper/**/*.xml"));
factory.setTypeHandlersPackage("com.rymcu.forest.util.handlers");
// factory.setTypeHandlersPackage("com.rymcu.forest.util.handlers");
return factory.getObject();
}

View File

@ -12,6 +12,8 @@ public class Author {
private String userNickname;
private String userAccount;
private String userAvatarURL;
private String userArticleCount;

View File

@ -39,10 +39,10 @@ public interface UserMapper extends Mapper<User> {
/**
* 根据用户昵称获取用户信息
* @param nickname
* @param account
* @return
*/
UserDTO selectUserDTOByNickname(@Param("nickname") String nickname);
UserDTO selectUserDTOByAccount(@Param("account") String account);
/**
* 修改用户密码

View File

@ -43,11 +43,11 @@ public interface UserService extends Service<User> {
Map login(String account, String password);
/**
* 通过 nickname 获取用户信息接口
* @param nickname 昵称
* 通过 account 获取用户信息接口
* @param account 昵称
* @return UserDTO
* */
UserDTO findUserDTOByNickname(String nickname);
UserDTO findUserDTOByAccount(String account);
/**
* 找回密码接口
@ -118,10 +118,10 @@ public interface UserService extends Service<User> {
/**
* 获取用户扩展信息
* @param nickname
* @param account
* @return
*/
UserExtend selectUserExtendByNickname(String nickname);
UserExtend selectUserExtendByAccount(String account);
/**
* 更换邮箱

View File

@ -388,9 +388,11 @@ public class ArticleServiceImpl extends AbstractService<Article> implements Arti
private Author genAuthor(ArticleDTO article) {
Author author = new Author();
User user = userService.findById(String.valueOf(article.getArticleAuthorId()));
author.setUserNickname(article.getArticleAuthorName());
author.setUserAvatarURL(article.getArticleAuthorAvatarUrl());
author.setIdUser(article.getArticleAuthorId());
author.setUserAccount(user.getAccount());
return author;
}
}

View File

@ -39,10 +39,7 @@ public class PortfolioServiceImpl extends AbstractService<Portfolio> implements
@Override
public List<PortfolioDTO> findUserPortfoliosByUser(UserDTO userDTO) {
List<PortfolioDTO> list = portfolioMapper.selectUserPortfoliosByIdUser(userDTO.getIdUser());
Author author = new Author();
author.setIdUser(userDTO.getIdUser());
author.setUserAvatarURL(userDTO.getAvatarUrl());
author.setUserNickname(userDTO.getNickname());
Author author = userService.selectAuthor(userDTO.getIdUser());
list.forEach(portfolioDTO -> {
genPortfolioAuthor(portfolioDTO,author);
});

View File

@ -116,8 +116,8 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
}
@Override
public UserDTO findUserDTOByNickname(String nickname) {
UserDTO user = userMapper.selectUserDTOByNickname(nickname);
public UserDTO findUserDTOByAccount(String account) {
UserDTO user = userMapper.selectUserDTOByAccount(account);
return user;
}
@ -239,7 +239,7 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
}
@Override
public UserExtend selectUserExtendByNickname(String nickname) {
public UserExtend selectUserExtendByAccount(String nickname) {
return userExtendMapper.selectUserExtendByNickname(nickname);
}

View File

@ -37,16 +37,16 @@ public class UserController {
@Resource
private FollowService followService;
@GetMapping("/{nickname}")
@GetMapping("/{account}")
@VisitLogger
public GlobalResult detail(@PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
public GlobalResult detail(@PathVariable String account){
UserDTO userDTO = userService.findUserDTOByAccount(account);
return GlobalResultGenerator.genSuccessResult(userDTO);
}
@GetMapping("/{nickname}/articles")
public GlobalResult userArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
@GetMapping("/{account}/articles")
public GlobalResult userArticles(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
UserDTO userDTO = userService.findUserDTOByAccount(account);
if (userDTO == null){
return GlobalResultGenerator.genErrorResult("用户不存在!");
}
@ -57,9 +57,9 @@ public class UserController {
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/{nickname}/portfolios")
public GlobalResult userPortfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
@GetMapping("/{account}/portfolios")
public GlobalResult userPortfolios(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
UserDTO userDTO = userService.findUserDTOByAccount(account);
if (userDTO == null){
return GlobalResultGenerator.genErrorResult("用户不存在!");
}
@ -73,9 +73,9 @@ public class UserController {
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/{nickname}/followers")
public GlobalResult userFollowers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
@GetMapping("/{account}/followers")
public GlobalResult userFollowers(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
UserDTO userDTO = userService.findUserDTOByAccount(account);
if (userDTO == null){
return GlobalResultGenerator.genErrorResult("用户不存在!");
}
@ -89,9 +89,9 @@ public class UserController {
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/{nickname}/followings")
public GlobalResult userFollowings(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String nickname){
UserDTO userDTO = userService.findUserDTOByNickname(nickname);
@GetMapping("/{account}/followings")
public GlobalResult userFollowings(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "12") Integer rows, @PathVariable String account){
UserDTO userDTO = userService.findUserDTOByAccount(account);
if (userDTO == null){
return GlobalResultGenerator.genErrorResult("用户不存在!");
}
@ -105,9 +105,9 @@ public class UserController {
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/{nickname}/user-extend")
public GlobalResult userExtend(@PathVariable String nickname) {
UserExtend userExtend = userService.selectUserExtendByNickname(nickname);
@GetMapping("/{account}/user-extend")
public GlobalResult userExtend(@PathVariable String account) {
UserExtend userExtend = userService.selectUserExtendByAccount(account);
return GlobalResultGenerator.genSuccessResult(userExtend);
}

View File

@ -44,7 +44,7 @@ public class WxoAuthController {
baseUrl = new StringBuilder(domain).append(contextPath);
}
StringBuilder accessTokenUrl = baseUrl.append("/wx/oauth/" + appId + "/getAccessToken?redirectUrl=").append(URIUtil.encodeURIComponent(redirectUrl));
String oauth2Url = wxMpService.getOAuth2Service().buildAuthorizationUrl(accessTokenUrl.toString(), WxConsts.OAuth2Scope.SNSAPI_BASE, null);
String oauth2Url = wxMpService.getOAuth2Service().buildAuthorizationUrl(accessTokenUrl.toString(), WxConsts.OAuth2Scope.SNSAPI_USERINFO, null);
return "redirect:" + oauth2Url;
}

View File

@ -45,6 +45,7 @@
<result column="id" property="idUser"/>
<result column="nickname" property="userNickname"/>
<result column="avatar_url" property="userAvatarURL"/>
<result column="account" property="userAccount"/>
</resultMap>
<insert id="insertUserRole">
insert into forest_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate())
@ -81,8 +82,8 @@
<select id="findUserInfoByAccount" resultMap="UserInfoResultMapper">
select id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from forest_user where account = #{account}
</select>
<select id="selectUserDTOByNickname" resultMap="DTOResultMapper">
select id, nickname, avatar_type, avatar_url, account, signature from forest_user where nickname = #{nickname} and status = 0
<select id="selectUserDTOByAccount" resultMap="DTOResultMapper">
select id, nickname, avatar_type, avatar_url, account, signature from forest_user where account = #{account} and status = 0
</select>
<select id="selectRoleWeightsByUser" resultType="java.lang.Integer">
select vr.weights from forest_role vr left join forest_user_role vur on vr.id = vur.id_role where vur.id_user = #{idUser}

View File

@ -6,6 +6,11 @@
"name": "官方网站",
"url": "https://rymcu.com"
},
{
"type": "view",
"name": "交流群",
"url": "https://mp.weixin.qq.com/s/0XDVL3mgrSpeGEALOQz-4Q"
},
{
"name": "学习教程",
"sub_button": [