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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
771 additions
and
0 deletions
+771
-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
+380
-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
package
com
.
zhiweidata
.
fpm
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.zhiweidata.fpm.dao.CacheDao
;
import
com.zhiweidata.fpm.model.AppPushEntity
;
import
com.zhiweidata.fpm.model.LogEntity
;
import
com.zhiweidata.fpm.model.management.ManagerEntity
;
import
com.zhiweidata.fpm.model.person.PersonBasicEntity
;
import
com.zhiweidata.fpm.model.person.PersonSearchEntity
;
import
com.zhiweidata.fpm.service.*
;
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.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 管理后台及相关人工干预管理接口(功能拆分混乱)
* Created by VoliBear on 2017/5/25.
* ©2012-2015 lightningbear.org, All Rights Reserved.
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
@Controller
@RequestMapping
(
"/api/manage"
)
public
class
ManagementController
{
@Autowired
private
ManagementService
managementService
;
@Autowired
private
ManagerPermissionService
managerPermissionService
;
@Autowired
private
AuthorizationService
authorizationService
;
@Autowired
private
CacheDao
cacheDao
;
@Autowired
private
EventServices
eventServices
;
private
static
final
Logger
logger
=
Logger
.
getLogger
(
MarketCompanyController
.
class
);
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertReportKeyword/{id}/{keyword} 插入划线关键词对应接口
* @apiDescription 插入划线关键词对应接口
* @apiParam {String} id 文章id
* @apiParam {String} keyword 关键词,多关键词下划线分割
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123/关键词?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertReportKeyword/{id}/{keyword}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
Object
getGeneralCompanyBasic
(
HttpServletRequest
request
,
@PathVariable
String
id
,
@PathVariable
String
keyword
)
{
return
JSONObject
.
toJSONString
(
managementService
.
insertReportKeyword
(
id
,
keyword
));
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/getPersonPush 获取人物搜索首页推送
* @apiDescription 获取人物搜索首页推送
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* ?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/getPersonPush"
,
method
=
RequestMethod
.
GET
)
public
Object
getPersonPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"push"
,
"get"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
getPersonPush
()),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertPersonPush/{id}/{company} 插入人物搜索首页推送
* @apiDescription 插入人物搜索首页推送
* @apiParam {String} id 人物id
* @apiParam {String} company 公司名
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123/阿里巴巴?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertPersonPush/{id}/{company}"
,
method
=
RequestMethod
.
GET
)
public
Object
insertPersonPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@PathVariable
String
company
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"push"
,
"insert"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
insertPersonPush
(
id
,
company
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/getPersonByName/{name} 根据人名获取人物基本信息列表
* @apiDescription 根据人名获取人物基本信息列表
* @apiParam {String} name 人名
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /zzm?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/getPersonByName/{name}"
,
method
=
RequestMethod
.
GET
)
public
Object
getPersonByName
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
name
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"push"
,
"search"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
searchPersonBasicByName
(
name
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/getPersonById/{id} 根据人物Id获取基本信息
* @apiDescription 根据人物Id获取基本信息
* @apiParam {String} id 人物ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/getPersonById/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
getPersonById
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
Long
id
,
@RequestParam
String
callback
)
{
PersonBasicEntity
personBasicEntity
=
managementService
.
searchPersonBasicById
(
id
);
return
authAndGetJsonp
(
"person"
,
"push"
,
"searchById"
,
false
,
callback
,
JSON
.
toJSONString
(
personBasicEntity
),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/removePersonById/{id} 根据ID删除人物推送
* @apiDescription 根据ID删除人物推送
* @apiParam {String} id 人物ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/removePersonById/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
removePersonPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"push"
,
"remove"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
removePersonPush
(
id
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/flushPersonCache 清除所有人物缓存信息
* @apiDescription 清除所有人物缓存信息
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* ?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/flushPersonCache"
,
method
=
RequestMethod
.
GET
)
public
Object
flushCache
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"push"
,
"flush"
,
false
,
callback
,
JSON
.
toJSONString
(
cacheDao
.
flushDB
()),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/removePersonById/{id} 根据ID删除人物推送
* @apiDescription 根据ID删除人物推送
* @apiParam {String} id 人物ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /123?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/getCompanyPush"
)
public
Object
getCompanyPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"company"
,
"push"
,
"get"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
getCompanyPush
()),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/flushCompanyCache 清除所有企业缓存信息
* @apiDescription 清除所有企业缓存信息
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* ?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/flushCompanyCache"
,
method
=
RequestMethod
.
GET
)
public
Object
flushCompanyCache
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"company"
,
"push"
,
"flush"
,
false
,
callback
,
JSON
.
toJSONString
(
cacheDao
.
flushDB
()),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertCompanyPush/{id} 插入企业库搜索首页推送
* @apiDescription 插入企业库搜索首页推送
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertCompanyPush/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
insertCompanyPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"company"
,
"push"
,
"insert"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
insertCompanyPush
(
id
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/removeCompanyById/{id} 删除企业库搜索首页推送
* @apiDescription 删除企业库搜索首页推送
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/removeCompanyById/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
removeCompanyById
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"company"
,
"push"
,
"remove"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
removeCompanyPush
(
id
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertCompanyToIndex/{id} 添加或刷新企业在全文检索中的信息
* @apiDescription 添加或刷新企业在全文检索中的信息
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertCompanyToIndex/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
insertCompanyToIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"company"
,
"index"
,
"insert"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
indexInsertCompanyIndex
(
id
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertPersonToIndex/{id} 添加或刷新人物在全文检索中的信息
* @apiDescription 添加或刷新人物在全文检索中的信息
* @apiParam {String} id 企业ID
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertPersonToIndex/{id}"
,
method
=
RequestMethod
.
GET
)
public
Object
insertPersonToIndex
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"person"
,
"index"
,
"insert"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
indexInsertPersonIndex
(
id
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/searchEvent 根据关键词查询事件接口
* @apiDescription 根据关键词查询事件接口 (JsonP方式)
* @apiParam {json} param {keyword:'事件名'}
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/searchEvent"
,
method
=
RequestMethod
.
GET
)
public
Object
searchEventsByKeyword
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@RequestParam
String
param
,
@RequestParam
String
callback
)
{
JSONObject
params
=
JSONObject
.
parseObject
(
param
);
String
keyword
=
null
;
try
{
keyword
=
URLDecoder
.
decode
(
params
.
getString
(
"keyword"
),
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
JSONObject
object
=
new
JSONObject
();
object
.
put
(
"list"
,
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
eventServices
.
getEventsByKeyword
(
keyword
))));
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"data"
,
object
);
return
authAndGetJsonp
(
"event"
,
"list"
,
"search"
,
false
,
callback
,
data
.
toJSONString
(),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/insertAppPush/{id}/{target} 插入App 头部推送
* @apiDescription 插入App 头部推送
* @apiParam {String} id 企业ID,人物ID,事件ID
* @apiParam {String} target 分类(index,event)
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223/index?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/insertAppPush/{id}/{target}"
,
method
=
RequestMethod
.
GET
)
public
Object
insertAppPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@PathVariable
String
target
,
@RequestParam
String
callback
)
{
return
authAndGetJsonp
(
"appPush"
,
"index"
,
"insert"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
insertAppPushById
(
id
,
target
)),
request
,
response
);
}
/**
* @apiGroup 管理后台及相关人工干预管理接口
* @api {get} /api/manage/removeAppPush/{id}/{target} 删除App 头部推送
* @apiDescription 删除App 头部推送
* @apiParam {String} id 企业ID,人物ID,事件ID
* @apiParam {String} target 分类(index,event)
* @apiParam {String} callback 回调
* @apiParamExample {string} 请求参数格式:
* /223/index?callback=
*/
@ResponseBody
@RequestMapping
(
value
=
"/removeAppPush/{id}/{target}"
,
method
=
RequestMethod
.
GET
)
public
Object
removeAppPush
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
String
id
,
@PathVariable
String
target
,
@RequestParam
String
callback
)
{
if
(
target
.
contains
(
"company"
))
{
target
=
"companyChannel"
;
}
return
authAndGetJsonp
(
"appPush"
,
"index"
,
"remove"
,
false
,
callback
,
JSON
.
toJSONString
(
managementService
.
removeAppPushById
(
id
,
target
)),
request
,
response
);
}
private
Object
authAndGetJsonp
(
String
database
,
String
type
,
String
item
,
boolean
isCache
,
String
callback
,
String
cacheString
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//Map<String, Object> authResult = authorizationService.authProUserInfo(request.getCookies(), response);
String
uid
=
null
;
boolean
isAuth
=
false
;
String
message
=
"success"
;
LogEntity
logEntity
=
new
LogEntity
();
JSONObject
jsonObject
=
new
JSONObject
();
Cookie
[]
cookies
=
request
.
getCookies
();
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
request
.
getCookies
())
{
if
(
cookie
.
getName
().
equals
(
"SA_USER_UID"
))
{
uid
=
cookie
.
getValue
();
break
;
}
}
}
if
(
uid
!=
null
)
{
ManagerEntity
managerEntity
=
null
;
try
{
managerEntity
=
managerPermissionService
.
authManagerById
(
uid
);
if
(
managerEntity
.
getPermission
()
<
0
)
{
managerEntity
=
null
;
}
}
catch
(
Exception
e
)
{
message
=
e
.
toString
();
}
if
(
managerEntity
!=
null
)
{
isAuth
=
true
;
logEntity
.
setAuth
(
true
);
}
else
{
message
=
"no permission"
;
logEntity
.
setAuth
(
false
);
}
}
else
{
message
=
"no login"
;
logEntity
.
setAuth
(
false
);
}
// managerPermissionService.authManagerById()
if
(!
isAuth
)
{
Tools
.
clearCookies
(
response
);
}
String
page
=
request
.
getHeader
(
"Referer"
);
logEntity
.
setPid
(
"management"
);
logEntity
.
setTimestamp
(
System
.
currentTimeMillis
());
logEntity
.
setItem
(
item
);
logEntity
.
setType
(
type
);
logEntity
.
setDatabase
(
database
);
logEntity
.
setUserAgent
(
request
.
getHeader
(
"User-Agent"
));
logEntity
.
setIp
(
Tools
.
getIpAddr
(
request
));
logEntity
.
setPort
(
String
.
valueOf
(
request
.
getRemotePort
()));
logEntity
.
setUid
(
uid
);
logEntity
.
setAuth
(
isAuth
);
logEntity
.
setCache
(
false
);
logEntity
.
setInfo
(
message
);
logEntity
.
setMode
(
callback
!=
null
?
"Jsonp"
:
"Json"
);
logEntity
.
setReferer
(
page
);
logger
.
info
(
JSON
.
toJSONString
(
logEntity
,
SerializerFeature
.
DisableCircularReferenceDetect
));
if
(!
isAuth
)
{
cacheString
=
"false"
;
}
MappingJacksonValue
mappingJacksonValue
=
new
MappingJacksonValue
(
JSON
.
parse
(
cacheString
));
mappingJacksonValue
.
setJsonpFunction
(
callback
);
return
mappingJacksonValue
;
}
}
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