Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apidoc-demo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apidoc-demo
Commits
0c952c20
Commit
0c952c20
authored
Dec 29, 2017
by
zhongzhimiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parents
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
391 additions
and
0 deletions
+391
-0
apidoc.json
+9
-0
src/main/java/com/zhiweidata/fpm/controller/GeneralCompanyController.java
+265
-0
src/main/java/com/zhiweidata/fpm/controller/GroupGraphController.java
+117
-0
src/main/java/com/zhiweidata/fpm/controller/ManagementController.java
+0
-0
No files found.
apidoc.json
0 → 100644
View file @
0c952c20
{
"name"
:
"任务企业库接口"
,
"version"
:
"1.0.0"
,
"description"
:
"接口测试"
,
"title"
:
"test APIs"
,
"url"
:
"http://localhost:8080/"
,
"sampleUrl"
:
"http://localhost:8080/"
}
\ No newline at end of file
src/main/java/com/zhiweidata/fpm/controller/GeneralCompanyController.java
0 → 100644
View file @
0c952c20
package
com
.
zhiweidata
.
fpm
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.zhiweidata.fpm.dao.CacheDao
;
import
com.zhiweidata.fpm.model.LogEntity
;
import
com.zhiweidata.fpm.service.AuthorizationService
;
import
com.zhiweidata.fpm.service.CompanyService
;
import
com.zhiweidata.fpm.utils.Tools
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.converter.json.MappingJacksonValue
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
/**
* 企业库-非上市公司(启信宝)数据web接口
* Created by VoliBear on 2017/5/22.
* ©2012-2015 lightningbear.org, All Rights Reserved.
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
@Controller
@RequestMapping
(
"/api/general"
)
public
class
GeneralCompanyController
{
@Autowired
private
CompanyService
companyService
;
@Autowired
private
CacheDao
cacheDao
;
@Autowired
private
AuthorizationService
authorizationService
;
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GeneralCompanyController
.
class
);
/**
* @apiGroup 企业库-非上市公司(启信宝)数据web接口
* @api {get} /api/general/get/{id} 根据ID获取企业数据
* @apiDescription 根据ID获取企业数据
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
* @apiSuccessExample {json} 正确返回值:
* {
* currencyType: "人民币",
* area: "深圳市南山区高新南一道009号中国科技开发院中科研发园三号楼塔楼22楼A",
* indexNum: 0,
* telephoneNums: "13316904999",
* created: "2007-12-26 00:00:00.0",
* listStatus: "存续(在营、开业、在册)",
* businessScope: "网络设备、电子产品、,限制的项目须取得许可后方可经营)",
* industry: "信息传输、软件和信息技术服务业",
* type: "有限责任公司",
* emails: "chengxianjia@teeqee.com,1301611745@qq.com",
* urls: "www.kwimg.cn",
* registeredCapital: 1000,
* legalPerson: "王欣",
* name: "深圳市快播科技有限公司",
* id: 800706583
* }
*/
@ResponseBody
@RequestMapping
(
value
=
"/get/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
getGeneralCompanyBasic
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
id
,
"basic"
,
callback
,
request
,
response
);
}
/**
* @apiGroup 企业库-非上市公司(启信宝)数据web接口
* @api {get} /api/general/getQXBCompanyByName/{name} 根据公司名获取企业信息
* @apiDescription 根据公司名获取企业信息
* @apiParam {String} name 企业名称
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /ali?callback=
* @apiSuccessExample {json} 正确返回值:
* {
* currencyType: "人民币",
* area: "深圳市南山区高新南一道009号中国科技开发院中科研发园三号楼塔楼22楼A",
* indexNum: 0,
* telephoneNums: "13316904999",
* created: "2007-12-26 00:00:00.0",
* listStatus: "存续(在营、开业、在册)",
* businessScope: "网络设备、电子产品、,限制的项目须取得许可后方可经营)",
* industry: "信息传输、软件和信息技术服务业",
* type: "有限责任公司",
* emails: "chengxianjia@teeqee.com,1301611745@qq.com",
* urls: "www.kwimg.cn",
* registeredCapital: 1000,
* legalPerson: "王欣",
* name: "深圳市快播科技有限公司",
* id: 800706583
* }
*/
@ResponseBody
@RequestMapping
(
value
=
"/getQXBCompanyByName/{name}"
,
method
=
RequestMethod
.
GET
)
public
Object
getGeneralCompanyBasicByName
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
name
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
name
,
"basicName"
,
callback
,
request
,
response
);
}
/**
* @apiGroup 企业库-非上市公司(启信宝)数据web接口
* @api {get} /api/general/getFocus/{id} 根据ID获取公司关系图
* @apiDescription 根据ID获取公司关系图
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
* @apiSuccessExample {json} 正确返回值:
* <p>
* nodes: [
* {
* parent:"深圳市快播科技有限公司",
* tier:1,
* symbolSize:20,
* name:"股东",
* tooltip:{
* show:false
* },
* itemStyle:
* {
* normal:
* {
* color:"#7C68A3"
* }
* },
* label:
* {
* normal:
* {
* show:true,
* position:"bottom"
* }
* }
* }
* ],
* edges: [
* {
* tooltip:
* {
* show:false
* },
* source:"深圳市快播科技有限公司",
* label:{
* show:false
* }
* ],
* nodeInfo:
* {
* 股东: [
* {
* name:"何明科",
* duty:"2150000万元人民币",
* time:"未公开",
* type:"自然人",
* radio:215000
* }
* ],
* 主要人员: [
* {
* name:"胡欢",
* duty:"董事",
* type:"主要人员"
* }
* ]
* }
* }
* ]
*/
@ResponseBody
@RequestMapping
(
value
=
"/getFocus/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
getFocus
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
id
,
"focus"
,
callback
,
request
,
response
);
}
/**
* @apiGroup 企业库-非上市公司(启信宝)数据web接口
* @api {get} /api/general/getModify/{id} 根据ID 获取历史变更信息
* @apiDescription 根据ID 获取历史变更信息
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
* @apiSuccessExample {json} 正确返回值:
* {
* modify: [
* {
* before: "网络设备、电子产品、计算机软硬件的技术开发和销售",
* after: "网络设备、电子产品、计算机软硬件的技术开发和销售",
* time: 1392134400000,
* type: "经营范围",
* seq: 1
* }]}
*/
@ResponseBody
@RequestMapping
(
value
=
"/getModify/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
getModify
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
id
,
"modify"
,
callback
,
request
,
response
);
}
private
Object
authAndGetJsonp
(
String
id
,
String
type
,
String
callback
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
Object
>
authResult
=
authorizationService
.
authProUserInfo
(
request
.
getCookies
(),
response
);
String
cacheId
=
type
+
id
;
boolean
isCache
=
true
;
boolean
isAuth
=
false
;
String
cacheString
;
cacheString
=
cacheDao
.
get
(
cacheId
);
if
(
cacheString
==
null
)
{
isCache
=
false
;
JSONObject
object
=
null
;
switch
(
type
)
{
case
"basic"
:
object
=
companyService
.
getGeneralCompanyBasicById
(
id
);
break
;
case
"basicName"
:
object
=
companyService
.
getQXBCompanyByName
(
id
);
break
;
case
"focus"
:
object
=
companyService
.
getGeneralCompanyFocusGraph
(
id
);
break
;
case
"modify"
:
object
=
companyService
.
getGeneralCompanyModify
(
id
);
break
;
}
if
(
object
!=
null
)
{
cacheString
=
JSON
.
toJSONString
(
object
,
SerializerFeature
.
DisableCircularReferenceDetect
);
cacheDao
.
add
(
cacheId
,
cacheString
);
}
}
if
(
authResult
.
get
(
"auth"
)
!=
null
&
Integer
.
valueOf
(
authResult
.
get
(
"auth"
).
toString
())
==
0
)
{
isAuth
=
true
;
}
else
{
Tools
.
clearCookies
(
response
);
}
String
page
=
request
.
getHeader
(
"Referer"
);
LogEntity
logEntity
=
new
LogEntity
();
logEntity
.
setPid
(
id
);
logEntity
.
setItem
(
type
);
logEntity
.
setType
(
"qxb"
);
logEntity
.
setDatabase
(
"company"
);
logEntity
.
setUserAgent
(
request
.
getHeader
(
"User-Agent"
));
logEntity
.
setIp
(
Tools
.
getIpAddr
(
request
));
logEntity
.
setPort
(
String
.
valueOf
(
request
.
getRemotePort
()));
logEntity
.
setUid
(
authResult
.
get
(
"uid"
).
toString
());
logEntity
.
setAuth
(
isAuth
);
logEntity
.
setTimestamp
(
System
.
currentTimeMillis
());
logEntity
.
setCache
(
isCache
);
logEntity
.
setInfo
(
authResult
.
get
(
"message"
).
toString
());
logEntity
.
setMode
(
callback
!=
null
?
"Jsonp"
:
"Json"
);
logEntity
.
setReferer
(
page
);
logger
.
info
(
JSON
.
toJSONString
(
logEntity
,
SerializerFeature
.
DisableCircularReferenceDetect
));
MappingJacksonValue
mappingJacksonValue
=
new
MappingJacksonValue
(
JSONObject
.
parse
(
cacheString
));
mappingJacksonValue
.
setJsonpFunction
(
callback
);
return
mappingJacksonValue
;
}
}
src/main/java/com/zhiweidata/fpm/controller/GroupGraphController.java
0 → 100644
View file @
0c952c20
package
com
.
zhiweidata
.
fpm
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.zhiweidata.fpm.dao.CacheDao
;
import
com.zhiweidata.fpm.model.LogEntity
;
import
com.zhiweidata.fpm.service.AuthorizationService
;
import
com.zhiweidata.fpm.service.GroupGraphService
;
import
com.zhiweidata.fpm.utils.Tools
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.converter.json.MappingJacksonValue
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
/**
* 财团图谱web接口
* Created by VoliBear on 2017/10/11.
* ©2012-2015 lightningbear.org, All Rights Reserved.
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
@Controller
@RequestMapping
(
"/api/group"
)
public
class
GroupGraphController
{
private
static
final
Logger
logger
=
Logger
.
getLogger
(
GeneralCompanyController
.
class
);
@Autowired
private
GroupGraphService
groupGraphService
;
@Autowired
private
AuthorizationService
authorizationService
;
@Autowired
private
CacheDao
cacheDao
;
/**
* @apiGroup 财团图谱web接口
* @api {get} /api/group/get/{id} 获取财团图谱
* @apiDescription 获取财团图谱
* @apiParam {String} id 财团图谱ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /ali?callback=
* @apiSuccessExample {json} 正确返回值:
* {
* "msg": "success",
* "code": 0,
* "data": {
* "nodes": [
* {
* "name": "马云",
* "x": "145.0",
* "y": 210,
* "id": "301026048",
* "category": 0
* }
* ]
* }
* }
*/
@ResponseBody
@RequestMapping
(
value
=
"/get/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
getGroupGraphById
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
id
,
"graph"
,
callback
,
request
,
response
);
}
private
Object
authAndGetJsonp
(
String
id
,
String
type
,
String
callback
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
Object
>
authResult
=
authorizationService
.
authProUserInfo
(
request
.
getCookies
(),
response
);
String
cacheId
=
type
+
id
;
boolean
isCache
=
true
;
boolean
isAuth
=
false
;
String
cacheString
;
cacheString
=
cacheDao
.
get
(
cacheId
);
if
(
cacheString
==
null
)
{
isCache
=
false
;
JSONObject
object
=
null
;
object
=
groupGraphService
.
getGroupGraphById
(
id
);
if
(
object
!=
null
)
{
cacheString
=
JSON
.
toJSONString
(
object
,
SerializerFeature
.
DisableCircularReferenceDetect
);
cacheDao
.
add
(
cacheId
,
cacheString
);
}
}
if
(
authResult
.
get
(
"auth"
)
!=
null
&
Integer
.
valueOf
(
authResult
.
get
(
"auth"
).
toString
())
==
0
)
{
isAuth
=
true
;
}
else
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"code"
,
"-2"
);
jsonObject
.
put
(
"msg"
,
"no auth"
);
cacheString
=
jsonObject
.
toJSONString
();
Tools
.
clearCookies
(
response
);
}
String
page
=
request
.
getHeader
(
"Referer"
);
LogEntity
logEntity
=
new
LogEntity
();
logEntity
.
setPid
(
id
);
logEntity
.
setItem
(
type
);
logEntity
.
setType
(
"group"
);
logEntity
.
setDatabase
(
"group_graph"
);
logEntity
.
setUserAgent
(
request
.
getHeader
(
"User-Agent"
));
logEntity
.
setIp
(
Tools
.
getIpAddr
(
request
));
logEntity
.
setPort
(
String
.
valueOf
(
request
.
getRemotePort
()));
logEntity
.
setUid
(
authResult
.
get
(
"uid"
).
toString
());
logEntity
.
setAuth
(
isAuth
);
logEntity
.
setTimestamp
(
System
.
currentTimeMillis
());
logEntity
.
setCache
(
isCache
);
logEntity
.
setInfo
(
authResult
.
get
(
"message"
).
toString
());
logEntity
.
setMode
(
callback
!=
null
?
"Jsonp"
:
"Json"
);
logEntity
.
setReferer
(
page
);
logger
.
info
(
JSON
.
toJSONString
(
logEntity
,
SerializerFeature
.
DisableCircularReferenceDetect
));
MappingJacksonValue
mappingJacksonValue
=
new
MappingJacksonValue
(
JSONObject
.
parse
(
cacheString
));
mappingJacksonValue
.
setJsonpFunction
(
callback
);
return
mappingJacksonValue
;
}
}
src/main/java/com/zhiweidata/fpm/controller/ManagementController.java
0 → 100644
View file @
0c952c20
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment