This commit is contained in:
2023-05-23 15:22:36 +08:00
parent b11bf94612
commit 0bddfd3e0e
3 changed files with 29 additions and 1 deletions

View File

@@ -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 {

View File

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

View File

@@ -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();