提交
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
package com.wx.application.adapter.controller;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
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 com.wx.application.adapter.dto.qo.GorseQ;
|
||||||
|
import com.wx.application.base.BaseController;
|
||||||
|
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.nebula.graph.query.NebulaModel;
|
||||||
|
import com.wx.application.nebula.graph.query.NebulaNode;
|
||||||
|
import com.wx.application.nebula.graph.service.NebulaOperateService;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/gorse")
|
||||||
|
@RestController("gorseController")
|
||||||
|
public class GorseController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
GorseService gorseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RiskUserService riskUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
EntrysService entrysService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
NebulaOperateService nebulaOperateService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推荐
|
||||||
|
* @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));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.wx.application.adapter.dto.qo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
public class GorseQ {
|
||||||
|
|
||||||
|
private String userId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
package com.wx.application.core.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.wx.application.base.BaseController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.wx.application.core.service.CategoryService;
|
||||||
|
import com.wx.application.core.entity.Category;
|
||||||
|
import com.wx.application.base.ResponseData;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.io.Serializable;
|
||||||
|
/**
|
||||||
|
* @description : Category 默认控制器,仅供生成器使用
|
||||||
|
* ---------------------------------
|
||||||
|
* @since 2023-05-23
|
||||||
|
*/
|
||||||
|
/*@Slf4j*/
|
||||||
|
@RestController("coreCategoryController")
|
||||||
|
@RequestMapping("//category")
|
||||||
|
public class CategoryController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义一些通用的错误信息,供其他 api引用
|
||||||
|
* @apiDefine DefaultException
|
||||||
|
* @apiError {String} code 错误码
|
||||||
|
* @apiError {String} msg 错误描述
|
||||||
|
* @apiError {String} requestId 请求id标识
|
||||||
|
*
|
||||||
|
* @apiErrorExample Error-Response:
|
||||||
|
* HTTP/1.1 200
|
||||||
|
* {
|
||||||
|
* "code": "UNAUTHORIZED",
|
||||||
|
* "msg": "未授权,请先登录",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义标准对象请求的结构体,供api引用
|
||||||
|
* @apiDefine CategoryReq
|
||||||
|
* @apiParam {String} name
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义标准对象返回的结构体,供api引用
|
||||||
|
* @apiDefine CategoryResp
|
||||||
|
* @apiSuccess {String} name
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义标准头部,供api引用
|
||||||
|
* @apiDefine CategoryHeader
|
||||||
|
* @apiHeader {String} Authorization 用户授权token
|
||||||
|
* @apiHeaderExample {json} Header-Example:
|
||||||
|
* {
|
||||||
|
* "Authorization": "Bearer 1eyJhbGciOiJIUzI1NiJ9....tzNK43MPVQWYYhDwihCAZa88zXzar7KLdgiBBDuUpBM",
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/query_unique 通过条件查询对象
|
||||||
|
* @apiName 通过条件查询对象
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiUse CategoryResp
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": {
|
||||||
|
|
||||||
|
"name": null,
|
||||||
|
* },
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 通过条件查询对象
|
||||||
|
* 仅查询第一条
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/query_unique")
|
||||||
|
public ResponseData queryUnique(@RequestBody Map categoryQ) {
|
||||||
|
return success(categoryService.queryUnique(categoryQ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/query_pages 通过条件分页查询列表
|
||||||
|
* @apiName 通过条件分页查询列表
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiUse CategoryResp
|
||||||
|
* @apiSuccess {Long} total 总数
|
||||||
|
* @apiSuccess {Long} size 分页大小
|
||||||
|
* @apiSuccess {Long} current 当前页
|
||||||
|
* @apiSuccess {Long} orders 排序
|
||||||
|
* @apiSuccess {Long} pages 总页数
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": {
|
||||||
|
* "records": [{
|
||||||
|
|
||||||
|
"name": null, * }],
|
||||||
|
* "total": 1,
|
||||||
|
* "size": 10,
|
||||||
|
* "current": 1,
|
||||||
|
* "orders": [],
|
||||||
|
* "searchCount": true,
|
||||||
|
* "pages": 1
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 通过条件分页查询列表
|
||||||
|
* 默认第一页 分页长度为10
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/query_pages")
|
||||||
|
public ResponseData queryPages(@RequestBody Map categoryQ) {
|
||||||
|
return success(categoryService.queryPage(categoryQ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/query_list 通过条件查询列表
|
||||||
|
* @apiName 通过条件查询列表
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiUse CategoryResp
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": [{
|
||||||
|
|
||||||
|
"name": null,
|
||||||
|
* }],
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 通过条件查询列表
|
||||||
|
* 不分页直接返回list
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/query_list")
|
||||||
|
public ResponseData queryList(@RequestBody Map categoryQ) {
|
||||||
|
return success(categoryService.queryList(categoryQ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/remove/:id 通过id删除单个记录
|
||||||
|
* @apiName 通过id删除单个记录
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiParam {PK} id 记录主键
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": true,
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 通过id删除单个记录
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/remove/{id}")
|
||||||
|
public ResponseData remove(@PathVariable("id") Serializable id) {
|
||||||
|
return success(categoryService.remove(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/modify 通过id更新单个记录
|
||||||
|
* @apiName 通过id更新单个记录
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiParam {PK} id 记录主键
|
||||||
|
* @apiUse CategoryReq
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": true,
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 通过id更新单个记录
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/modify")
|
||||||
|
public ResponseData modify(@RequestBody Category category) {
|
||||||
|
return success(categoryService.modify(category));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @api {post} //category/create 新增
|
||||||
|
* @apiName 新增
|
||||||
|
* @apiGroup Category
|
||||||
|
*
|
||||||
|
* @apiUse CategoryHeader
|
||||||
|
* @apiUse CategoryReq
|
||||||
|
* @apiSuccessExample Success-Response:
|
||||||
|
* HTTP/1.1 200 OK
|
||||||
|
* {
|
||||||
|
* "data": true,
|
||||||
|
* "code": "SUCCESS",
|
||||||
|
* "msg": "请求成功",
|
||||||
|
* "requestId": "163e2f67-5306-4b10-bcbe-a1579d589446"
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @apiUse DefaultException
|
||||||
|
*
|
||||||
|
* @description : 新增
|
||||||
|
* ---------------------------------
|
||||||
|
* @author : zj
|
||||||
|
* @since : Create in 2023-05-23
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/create")
|
||||||
|
public ResponseData create(@RequestBody Category category) {
|
||||||
|
return success(categoryService.create(category));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.wx.application.core.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.wx.application.base.BaseEntity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zj
|
||||||
|
* @since 2023-05-23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@TableName("re_category")
|
||||||
|
public class Category extends BaseEntity<Long> {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.wx.application.core.mapper;
|
||||||
|
|
||||||
|
import com.wx.application.core.entity.Category;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zj
|
||||||
|
* @since 2023-05-23
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface CategoryMapper extends BaseMapper<Category> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.wx.application.core.service;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import com.wx.application.base.BaseService;
|
||||||
|
import com.wx.application.core.entity.Category;
|
||||||
|
import com.wx.application.core.mapper.CategoryMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author zj
|
||||||
|
* @since 2023-05-23
|
||||||
|
*/
|
||||||
|
/*@Slf4j*/
|
||||||
|
@Service("coreCategoryService")
|
||||||
|
@Transactional
|
||||||
|
public class CategoryService extends BaseService<Category, CategoryMapper> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
CategoryMapper baseMapper;
|
||||||
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
package com.wx.application.core.service;
|
package com.wx.application.core.service;
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.wx.application.core.entity.Entrys;
|
|
||||||
import com.wx.application.base.BaseService;
|
import com.wx.application.base.BaseService;
|
||||||
|
import com.wx.application.core.entity.Entrys;
|
||||||
import com.wx.application.core.mapper.EntrysMapper;
|
import com.wx.application.core.mapper.EntrysMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package com.wx.application.core.service;
|
package com.wx.application.core.service;
|
||||||
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.wx.application.core.entity.FeedbackType;
|
|
||||||
import com.wx.application.base.BaseService;
|
import com.wx.application.base.BaseService;
|
||||||
|
import com.wx.application.core.entity.FeedbackType;
|
||||||
import com.wx.application.core.mapper.FeedbackTypeMapper;
|
import com.wx.application.core.mapper.FeedbackTypeMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,21 +10,20 @@ import java.net.URL;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Gorse {
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
private final String endpoint;
|
@Service
|
||||||
private final String apiKey;
|
public class GorseService {
|
||||||
|
|
||||||
|
private String endpoint = "http://43.139.83.67:8088/";
|
||||||
|
private String apiKey = "";
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
// Create a client.
|
// Create a client.
|
||||||
Gorse client = new Gorse("http://43.139.83.67:8088/", "");
|
//Gorse client = new Gorse("", "");
|
||||||
System.out.println(client.getRecommend("1265177464"));
|
//System.out.println(client.getRecommend("1265177464"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gorse(String endpoint, String apiKey) {
|
|
||||||
this.endpoint = endpoint;
|
|
||||||
this.apiKey = apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RowAffected insertUser(User user) throws IOException {
|
public RowAffected insertUser(User user) throws IOException {
|
||||||
return this.request("POST", this.endpoint + "/api/user", user, RowAffected.class);
|
return this.request("POST", this.endpoint + "/api/user", user, RowAffected.class);
|
||||||
6
api/src/main/resources/mapper/CategoryMapper.xml
Normal file
6
api/src/main/resources/mapper/CategoryMapper.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.wx.application.core.mapper.CategoryMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user