@Mapper
public interface UserMapper extends BaseMapper<User>{}
编写service类
@Service
@Slf4j
public class UserService {
`
/**
* 通过用户id获取用户信息(有缓存)
*
* @param id 用户id
* @return {@code User}
*/
public User getById(Long id){return userMapper.selectById(id);}}
编写Controller
@RestController
public class UserController{
String API_PREFIX ="/user";
@GetMapping(API_PREFIX + "/info")
public Response<UserVo> getUser(long userId){return Response.success(BeanUtil.copyProperties(userService.getById(userId), UserVo.class));}}