Joburgess 5 年之前
父节点
当前提交
897ba2ad60

+ 5 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ShortUrlController.java

@@ -4,6 +4,7 @@ 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.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.Objects;
 
 /**
  * @Author Joburgess
@@ -27,6 +29,9 @@ public class ShortUrlController extends BaseController {
     @GetMapping(value = "/su/{id}")
     public void redirectUrl(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
         ShortUrl shortUrl = shortUrlService.get(id);
+        if(Objects.isNull(shortUrl)|| StringUtils.isBlank(shortUrl.getUrl())){
+            return;
+        }
         response.sendRedirect(shortUrl.getUrl());
     }
 

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ShortUrlServiceImpl.java

@@ -37,7 +37,7 @@ public class ShortUrlServiceImpl extends BaseServiceImpl<Long, ShortUrl> impleme
 		SysConfig baseUrlConfig = sysConfigService.findByParamName(SysConfigService.BASE_API_URL);
 
 		StringBuffer returnUrl=new StringBuffer(baseUrlConfig.getParanValue());
-		returnUrl.append("/api-user/su/");
+		returnUrl.append("/su/");
 		returnUrl.append(shortUrl.getId());
 
 		return returnUrl.toString();