|  | @@ -0,0 +1,33 @@
 | 
	
		
			
				|  |  | +package com.keao.edu.user.controller;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.keao.edu.common.controller.BaseController;
 | 
	
		
			
				|  |  | +import com.keao.edu.user.entity.ShortUrl;
 | 
	
		
			
				|  |  | +import com.keao.edu.user.service.ShortUrlService;
 | 
	
		
			
				|  |  | +import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.stereotype.Controller;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.GetMapping;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.PathVariable;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.RequestMapping;
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * @Author Joburgess
 | 
	
		
			
				|  |  | + * @Date 2020.06.22
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +@Controller
 | 
	
		
			
				|  |  | +@RequestMapping("/")
 | 
	
		
			
				|  |  | +@Api(tags = "短链接服务")
 | 
	
		
			
				|  |  | +public class ShortUrlController extends BaseController {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ShortUrlService shortUrlService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @GetMapping(value = "/su/{id}")
 | 
	
		
			
				|  |  | +    public void redirectUrl(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
 | 
	
		
			
				|  |  | +        ShortUrl shortUrl = shortUrlService.get(id);
 | 
	
		
			
				|  |  | +        response.sendRedirect(shortUrl.getUrl());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |