zhangjian 2 лет назад
Родитель
Сommit
0bddfd3e0e

+ 21 - 1
api/src/main/java/com/wx/application/adapter/controller/GorseController.java

@@ -17,6 +17,7 @@ import com.wx.application.base.ResponseData;
 import com.wx.application.core.service.EntrysService;
 import com.wx.application.core.service.RiskUserService;
 import com.wx.application.gorse4j.GorseService;
+import com.wx.application.gorse4j.Item;
 import com.wx.application.nebula.graph.query.NebulaModel;
 import com.wx.application.nebula.graph.query.NebulaNode;
 import com.wx.application.nebula.graph.service.NebulaOperateService;
@@ -41,7 +42,7 @@ public class GorseController extends BaseController {
 	NebulaOperateService nebulaOperateService;
 	
 	/**
-	 * 推荐
+	 * 推荐根据userId
 	 * @param gQo
 	 * @return
 	 * @throws Exception
@@ -57,6 +58,25 @@ public class GorseController extends BaseController {
 		return success(entrysService.queryList(mQ));
 	}
 	
+	/**
+	 * 根据列表推荐
+	 * @param gQo
+	 * @return
+	 * @throws Exception
+	 */
+	@PostMapping(value = "/popular_by_category")
+    public ResponseData popularByCategory(@RequestBody GorseQ gQo) throws Exception {
+		List<Item> res = gorseService.getPopular(gQo.getCategory());
+		return success(res);
+	}
+	
+	
+	/**
+	 * 推荐根据知识图谱
+	 * @param gQo
+	 * @return
+	 * @throws Exception
+	 */
 	@PostMapping(value = "/recommend_by_userid_with_graph")
     public ResponseData recommendByUserIdWithGraph(@RequestBody GorseQ gQo) throws Exception {
 		

+ 1 - 0
api/src/main/java/com/wx/application/adapter/dto/qo/GorseQ.java

@@ -9,4 +9,5 @@ public class GorseQ {
 	
 	private String userId;
 	
+	private String category;
 }

+ 7 - 0
api/src/main/java/com/wx/application/gorse4j/GorseService.java

@@ -60,6 +60,13 @@ public class GorseService {
     public List<String> getRecommend(String userId) throws IOException {
         return Arrays.asList(this.request("GET", this.endpoint + "/api/recommend/" + userId, null, String[].class));
     }
+    
+    
+    public List<Item> getPopular(String category) throws IOException {
+        return Arrays.asList(this.request("GET", this.endpoint + "/api/dashboard/popular/" + category, null, Item[].class));
+    }
+    
+    
 
     private <Request, Response> Response request(String method, String url, Request request, Class<Response> responseClass) throws IOException {
         HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();