✨ 用户扩展-站点链接功能
This commit is contained in:
parent
c7b6b8a63b
commit
0a7e88ddda
28
src/main/java/com/rymcu/vertical/entity/UserExtend.java
Normal file
28
src/main/java/com/rymcu/vertical/entity/UserExtend.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package com.rymcu.vertical.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Table(name = "vertical_user_extend")
|
||||||
|
public class UserExtend {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private Integer idUser;
|
||||||
|
|
||||||
|
private String github;
|
||||||
|
|
||||||
|
private String weibo;
|
||||||
|
|
||||||
|
private String weixin;
|
||||||
|
|
||||||
|
private String qq;
|
||||||
|
|
||||||
|
private String blog;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.rymcu.vertical.mapper;
|
||||||
|
|
||||||
|
import com.rymcu.vertical.core.mapper.Mapper;
|
||||||
|
import com.rymcu.vertical.entity.UserExtend;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ronger
|
||||||
|
*/
|
||||||
|
public interface UserExtendMapper extends Mapper<UserExtend> {
|
||||||
|
/**
|
||||||
|
* 获取用户扩展信息
|
||||||
|
* @param nickname
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UserExtend selectUserExtendByNickname(@Param("nickname") String nickname);
|
||||||
|
}
|
@ -5,6 +5,7 @@ import com.rymcu.vertical.dto.Author;
|
|||||||
import com.rymcu.vertical.dto.UserDTO;
|
import com.rymcu.vertical.dto.UserDTO;
|
||||||
import com.rymcu.vertical.dto.UserInfoDTO;
|
import com.rymcu.vertical.dto.UserInfoDTO;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
|
import com.rymcu.vertical.entity.UserExtend;
|
||||||
import org.apache.ibatis.exceptions.TooManyResultsException;
|
import org.apache.ibatis.exceptions.TooManyResultsException;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -108,4 +109,18 @@ public interface UserService extends Service<User> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Author selectAuthor(Integer idUser);
|
Author selectAuthor(Integer idUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户扩展信息
|
||||||
|
* @param userExtend
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map updateUserExtend(UserExtend userExtend);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户扩展信息
|
||||||
|
* @param nickname
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
UserExtend selectUserExtendByNickname(String nickname);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,10 @@ import com.rymcu.vertical.dto.UserDTO;
|
|||||||
import com.rymcu.vertical.dto.UserInfoDTO;
|
import com.rymcu.vertical.dto.UserInfoDTO;
|
||||||
import com.rymcu.vertical.entity.Role;
|
import com.rymcu.vertical.entity.Role;
|
||||||
import com.rymcu.vertical.entity.User;
|
import com.rymcu.vertical.entity.User;
|
||||||
|
import com.rymcu.vertical.entity.UserExtend;
|
||||||
import com.rymcu.vertical.jwt.service.TokenManager;
|
import com.rymcu.vertical.jwt.service.TokenManager;
|
||||||
import com.rymcu.vertical.mapper.RoleMapper;
|
import com.rymcu.vertical.mapper.RoleMapper;
|
||||||
|
import com.rymcu.vertical.mapper.UserExtendMapper;
|
||||||
import com.rymcu.vertical.mapper.UserMapper;
|
import com.rymcu.vertical.mapper.UserMapper;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import com.rymcu.vertical.util.BeanCopierUtil;
|
import com.rymcu.vertical.util.BeanCopierUtil;
|
||||||
@ -24,6 +26,7 @@ import javax.annotation.Resource;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +44,8 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
@Resource
|
@Resource
|
||||||
private TokenManager tokenManager;
|
private TokenManager tokenManager;
|
||||||
|
@Resource
|
||||||
|
private UserExtendMapper userExtendMapper;
|
||||||
|
|
||||||
private final static String avatarSvgType = "1";
|
private final static String avatarSvgType = "1";
|
||||||
|
|
||||||
@ -165,7 +170,14 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
if (user == null) {
|
if (user == null) {
|
||||||
map.put("message", "用户不存在!");
|
map.put("message", "用户不存在!");
|
||||||
} else {
|
} else {
|
||||||
|
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(user.getIdUser());
|
||||||
|
if (Objects.isNull(userExtend)) {
|
||||||
|
userExtend = new UserExtend();
|
||||||
|
userExtend.setIdUser(user.getIdUser());
|
||||||
|
userExtendMapper.insertSelective(userExtend);
|
||||||
|
}
|
||||||
map.put("user", user);
|
map.put("user", user);
|
||||||
|
map.put("userExtend", userExtend);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -213,4 +225,21 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|||||||
public Author selectAuthor(Integer idUser) {
|
public Author selectAuthor(Integer idUser) {
|
||||||
return userMapper.selectAuthor(idUser);
|
return userMapper.selectAuthor(idUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map updateUserExtend(UserExtend userExtend) {
|
||||||
|
Map map = new HashMap(1);
|
||||||
|
int result = userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
||||||
|
if (result == 0) {
|
||||||
|
map.put("message", "操作失败!");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
map.put("userExtend", userExtend);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserExtend selectUserExtendByNickname(String nickname) {
|
||||||
|
return userExtendMapper.selectUserExtendByNickname(nickname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.rymcu.vertical.core.service.log.annotation.VisitLogger;
|
|||||||
import com.rymcu.vertical.dto.ArticleDTO;
|
import com.rymcu.vertical.dto.ArticleDTO;
|
||||||
import com.rymcu.vertical.dto.PortfolioDTO;
|
import com.rymcu.vertical.dto.PortfolioDTO;
|
||||||
import com.rymcu.vertical.dto.UserDTO;
|
import com.rymcu.vertical.dto.UserDTO;
|
||||||
|
import com.rymcu.vertical.entity.UserExtend;
|
||||||
import com.rymcu.vertical.service.ArticleService;
|
import com.rymcu.vertical.service.ArticleService;
|
||||||
import com.rymcu.vertical.service.FollowService;
|
import com.rymcu.vertical.service.FollowService;
|
||||||
import com.rymcu.vertical.service.PortfolioService;
|
import com.rymcu.vertical.service.PortfolioService;
|
||||||
@ -104,4 +105,10 @@ public class UserController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{nickname}/user-extend")
|
||||||
|
public GlobalResult userExtend(@PathVariable String nickname) {
|
||||||
|
UserExtend userExtend = userService.selectUserExtendByNickname(nickname);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(userExtend);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.rymcu.vertical.web.api.user;
|
|||||||
import com.rymcu.vertical.core.result.GlobalResult;
|
import com.rymcu.vertical.core.result.GlobalResult;
|
||||||
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
import com.rymcu.vertical.core.result.GlobalResultGenerator;
|
||||||
import com.rymcu.vertical.dto.UserInfoDTO;
|
import com.rymcu.vertical.dto.UserInfoDTO;
|
||||||
|
import com.rymcu.vertical.entity.UserExtend;
|
||||||
import com.rymcu.vertical.service.UserService;
|
import com.rymcu.vertical.service.UserService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -37,4 +38,10 @@ public class UserInfoController {
|
|||||||
return GlobalResultGenerator.genSuccessResult(map);
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PatchMapping("/update-extend")
|
||||||
|
public GlobalResult updateUserExtend(@RequestBody UserExtend userExtend) {
|
||||||
|
Map map = userService.updateUserExtend(userExtend);
|
||||||
|
return GlobalResultGenerator.genSuccessResult(map);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
16
src/main/java/mapper/UserExtendMapper.xml
Normal file
16
src/main/java/mapper/UserExtendMapper.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.rymcu.vertical.mapper.UserExtendMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.rymcu.vertical.entity.UserExtend">
|
||||||
|
<result column="id_user" property="idUser"></result>
|
||||||
|
<result column="github" property="github"></result>
|
||||||
|
<result column="weibo" property="weibo"></result>
|
||||||
|
<result column="weixin" property="weixin"></result>
|
||||||
|
<result column="qq" property="qq"></result>
|
||||||
|
<result column="blog" property="blog"></result>
|
||||||
|
</resultMap>
|
||||||
|
<select id="selectUserExtendByNickname" resultMap="BaseResultMap">
|
||||||
|
select vue.* from vertical_user_extend vue join vertical_user vu on vue.id_user = vu.id
|
||||||
|
where vu.nickname = #{nickname} limit 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user