♻️ 个人中心路径 /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> <dependency>
<groupId>com.thoughtworks.xstream</groupId> <groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId> <artifactId>xstream</artifactId>
<version>1.4.15</version> <version>1.4.16</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.jedis-lock</groupId> <groupId>com.github.jedis-lock</groupId>

View File

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

View File

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

View File

@ -39,10 +39,10 @@ public interface UserMapper extends Mapper<User> {
/** /**
* 根据用户昵称获取用户信息 * 根据用户昵称获取用户信息
* @param nickname * @param account
* @return * @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); Map login(String account, String password);
/** /**
* 通过 nickname 获取用户信息接口 * 通过 account 获取用户信息接口
* @param nickname 昵称 * @param account 昵称
* @return UserDTO * @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 * @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) { private Author genAuthor(ArticleDTO article) {
Author author = new Author(); Author author = new Author();
User user = userService.findById(String.valueOf(article.getArticleAuthorId()));
author.setUserNickname(article.getArticleAuthorName()); author.setUserNickname(article.getArticleAuthorName());
author.setUserAvatarURL(article.getArticleAuthorAvatarUrl()); author.setUserAvatarURL(article.getArticleAuthorAvatarUrl());
author.setIdUser(article.getArticleAuthorId()); author.setIdUser(article.getArticleAuthorId());
author.setUserAccount(user.getAccount());
return author; return author;
} }
} }

View File

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

View File

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

View File

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

View File

@ -44,7 +44,7 @@ public class WxoAuthController {
baseUrl = new StringBuilder(domain).append(contextPath); baseUrl = new StringBuilder(domain).append(contextPath);
} }
StringBuilder accessTokenUrl = baseUrl.append("/wx/oauth/" + appId + "/getAccessToken?redirectUrl=").append(URIUtil.encodeURIComponent(redirectUrl)); 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; return "redirect:" + oauth2Url;
} }
@ -58,8 +58,8 @@ public class WxoAuthController {
throw new Exception("无权限"); throw new Exception("无权限");
} }
WxMpUser wxMpUser =wxMpService.getUserService().userInfo(oAuth2AccessToken.getOpenId()); WxMpUser wxMpUser = wxMpService.getUserService().userInfo(oAuth2AccessToken.getOpenId());
wxUserService.saveUser(wxMpUser,appId); wxUserService.saveUser(wxMpUser, appId);
ContextHolderUtils.getSession2().setAttribute("wxUser", wxMpUser); ContextHolderUtils.getSession2().setAttribute("wxUser", wxMpUser);
return "redirect:" + redirectUrl; return "redirect:" + redirectUrl;
} }

View File

@ -45,6 +45,7 @@
<result column="id" property="idUser"/> <result column="id" property="idUser"/>
<result column="nickname" property="userNickname"/> <result column="nickname" property="userNickname"/>
<result column="avatar_url" property="userAvatarURL"/> <result column="avatar_url" property="userAvatarURL"/>
<result column="account" property="userAccount"/>
</resultMap> </resultMap>
<insert id="insertUserRole"> <insert id="insertUserRole">
insert into forest_user_role (id_user,id_role,created_time) values (#{idUser},#{idRole},sysdate()) 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="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 id, nickname, sex, avatar_type, avatar_url, email, phone, account, status, signature, last_login_time from forest_user where account = #{account}
</select> </select>
<select id="selectUserDTOByNickname" resultMap="DTOResultMapper"> <select id="selectUserDTOByAccount" resultMap="DTOResultMapper">
select id, nickname, avatar_type, avatar_url, account, signature from forest_user where nickname = #{nickname} and status = 0 select id, nickname, avatar_type, avatar_url, account, signature from forest_user where account = #{account} and status = 0
</select> </select>
<select id="selectRoleWeightsByUser" resultType="java.lang.Integer"> <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} 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": "官方网站", "name": "官方网站",
"url": "https://rymcu.com" "url": "https://rymcu.com"
}, },
{
"type": "view",
"name": "交流群",
"url": "https://mp.weixin.qq.com/s/0XDVL3mgrSpeGEALOQz-4Q"
},
{ {
"name": "学习教程", "name": "学习教程",
"sub_button": [ "sub_button": [