|
|
@@ -6,10 +6,7 @@ import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import com.wx.application.adapter.dto.qo.GorseQ;
|
|
|
import com.wx.application.base.BaseController;
|
|
|
@@ -29,82 +26,100 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@RequestMapping("/gorse")
|
|
|
@RestController("gorseController")
|
|
|
public class GorseController extends BaseController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- GorseService gorseService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- RiskUserService riskUserService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- EntrysService entrysService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- NebulaOperateService nebulaOperateService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ImportGraphService importGraphService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 推荐根据userId
|
|
|
- * @param gQo
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @PostMapping(value = "/recommend_by_userid")
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ GorseService gorseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RiskUserService riskUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ EntrysService entrysService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ NebulaOperateService nebulaOperateService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ImportGraphService importGraphService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推荐根据userId
|
|
|
+ *
|
|
|
+ * @param gQo
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/recommend_by_userid")
|
|
|
public ResponseData recommendByUserId(@RequestBody GorseQ gQo) throws Exception {
|
|
|
- List<String> res = gorseService.getRecommend(gQo.getUserId());
|
|
|
- if(res == null || res.size() == 0) {
|
|
|
- return success();
|
|
|
- }
|
|
|
- Map mQ = new HashMap<>();
|
|
|
- mQ.put("INS_fid", StringUtils.join(res, ","));
|
|
|
- return success(entrysService.queryList(mQ));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据列表推荐
|
|
|
- * @param gQo
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @PostMapping(value = "/popular_by_category")
|
|
|
+ List<String> res = gorseService.getRecommend(gQo.getUserId());
|
|
|
+ if (res == null || res.size() == 0) {
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ Map mQ = new HashMap<>();
|
|
|
+ mQ.put("INS_fid", StringUtils.join(res, ","));
|
|
|
+ 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);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(value = "/ipt")
|
|
|
+ List<Item> res = gorseService.getPopular(gQo.getCategory());
|
|
|
+ return success(res);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/ipt")
|
|
|
public ResponseData ipt() throws Exception {
|
|
|
- importGraphService.iptUser();
|
|
|
- importGraphService.iptentrys();
|
|
|
- return success();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 推荐根据知识图谱
|
|
|
- * @param gQo
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- @PostMapping(value = "/recommend_by_userid_with_graph")
|
|
|
+ importGraphService.iptUser();
|
|
|
+ importGraphService.iptentrys();
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推荐根据知识图谱
|
|
|
+ *
|
|
|
+ * @param gQo
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/recommend_by_userid_with_graph")
|
|
|
public ResponseData recommendByUserIdWithGraph(@RequestBody GorseQ gQo) throws Exception {
|
|
|
-
|
|
|
- NebulaModel nebulaModel = nebulaOperateService.findOnePathById("", gQo.getUserId());
|
|
|
- List<NebulaNode> nodes = nebulaModel.getNodes();
|
|
|
-
|
|
|
- if(nodes != null && nodes.size() > 0) {
|
|
|
- nodes.get(0).getVid();
|
|
|
- }
|
|
|
-
|
|
|
- List<String> res = gorseService.getRecommend(gQo.getUserId());
|
|
|
- if(res == null || res.size() == 0) {
|
|
|
- return success();
|
|
|
- }
|
|
|
- Map mQ = new HashMap<>();
|
|
|
- mQ.put("INS_fid", StringUtils.join(res, ","));
|
|
|
- return success(entrysService.queryList(mQ));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ NebulaModel nebulaModel = nebulaOperateService.findOnePathById("", gQo.getUserId());
|
|
|
+ List<NebulaNode> nodes = nebulaModel.getNodes();
|
|
|
+
|
|
|
+ if (nodes != null && nodes.size() > 0) {
|
|
|
+ nodes.get(0).getVid();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> res = gorseService.getRecommend(gQo.getUserId());
|
|
|
+ if (res == null || res.size() == 0) {
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+ Map mQ = new HashMap<>();
|
|
|
+ mQ.put("INS_fid", StringUtils.join(res, ","));
|
|
|
+ return success(entrysService.queryList(mQ));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/get_similar_user")
|
|
|
+ public ResponseData getSimilarUser(@RequestBody GorseQ gQo) throws Exception {
|
|
|
+ return success(gorseService.getSimilarUser(gQo.getUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/get_recommend_by_user")
|
|
|
+ public ResponseData getRecommendByUser(@RequestBody GorseQ gQo) throws Exception {
|
|
|
+ return success(gorseService.getRecommendByUser(gQo.getUserId(), gQo.getRecommendation(), gQo.getCategory(), gQo.getN()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/get_similar_item")
|
|
|
+ public ResponseData getSimilarItem(@RequestBody GorseQ gQo) throws Exception {
|
|
|
+ return success(gorseService.getSimilarItem(gQo.getItemId(), gQo.getCategory(), gQo.getN()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|