Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-analysis
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.online.exam
pica-cloud-analysis
提交
801f34a1
提交
801f34a1
编写于
9月 13, 2018
作者:
minghao.wu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev_phase3' into release
上级
4091212e
bbf27a3d
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
129 行增加
和
29 行删除
+129
-29
PropertiesConfiguration.java
...nalysis/server/configuration/PropertiesConfiguration.java
+11
-0
AnalysisController.java
...e/exam/analysis/server/controller/AnalysisController.java
+39
-9
AntiSpamController.java
...e/exam/analysis/server/controller/AntiSpamController.java
+49
-12
AntiSpamService.java
.../online/exam/analysis/server/service/AntiSpamService.java
+9
-1
CHCAnalysisService.java
...line/exam/analysis/server/service/CHCAnalysisService.java
+2
-1
AntiSpamServiceImpl.java
...xam/analysis/server/service/impl/AntiSpamServiceImpl.java
+17
-4
CHCAnalysisServiceImpl.java
.../analysis/server/service/impl/CHCAnalysisServiceImpl.java
+2
-2
未找到文件。
server/src/main/java/com/pica/cloud/online/exam/analysis/server/configuration/PropertiesConfiguration.java
浏览文件 @
801f34a1
...
...
@@ -22,6 +22,9 @@ public class PropertiesConfiguration {
@Value
(
"${netease.antispam.text.businessid}"
)
private
String
neteaseAntispamTextBusinessId
;
@Value
(
"${netease.antispam.text.ad.businessid}"
)
private
String
neteaseAntispamTextAdBusinessId
;
@Value
(
"${netease.antispam.image.apiurl}"
)
private
String
neteaseAntispamImageApiUrl
;
...
...
@@ -74,6 +77,14 @@ public class PropertiesConfiguration {
this
.
neteaseAntispamTextBusinessId
=
neteaseAntispamTextBusinessId
;
}
public
String
getNeteaseAntispamTextAdBusinessId
()
{
return
neteaseAntispamTextAdBusinessId
;
}
public
void
setNeteaseAntispamTextAdBusinessId
(
String
neteaseAntispamTextAdBusinessId
)
{
this
.
neteaseAntispamTextAdBusinessId
=
neteaseAntispamTextAdBusinessId
;
}
public
String
getNeteaseAntispamImageApiUrl
()
{
return
neteaseAntispamImageApiUrl
;
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AnalysisController.java
浏览文件 @
801f34a1
...
...
@@ -59,7 +59,13 @@ public class AnalysisController {
@Autowired
private
CHCRankingListService
rankingListService
;
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
/**
* TODO: chc错题解析活动和psa的活动id 需要前端传入
*/
static
final
Integer
CHC_ANALYSIS_ID
=
1
;
static
final
Integer
PSA_ANALYSIS_ID
=
2
;
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/activityDetail"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
CHCAnalysisDto
>
getActivityDetail
(
@RequestParam
(
required
=
false
)
Integer
id
,
@RequestHeader
(
required
=
false
)
String
token
)
{
...
...
@@ -68,7 +74,7 @@ public class AnalysisController {
/**
* 如果不传活动id进来,活动id就用1
*/
id
=
(
id
==
null
?
1
:
id
);
id
=
(
id
==
null
?
CHC_ANALYSIS_ID
:
id
);
try
{
CHCAnalysisDto
analysisDto
=
analysisService
.
getCHCAnalysisDtoById
(
id
);
...
...
@@ -111,7 +117,7 @@ public class AnalysisController {
/**
* 如果不传活动id进来,活动id就用1
*/
id
=
(
id
==
null
?
2
:
id
);
id
=
(
id
==
null
?
PSA_ANALYSIS_ID
:
id
);
try
{
CHCAnalysisDto
analysisDto
=
analysisService
.
getPSAAnalysisDtoById
(
id
);
...
...
@@ -170,7 +176,7 @@ public class AnalysisController {
/**
* TODO: 如果是PSA 删除时间显示
*/
if
(
analysisRoundExamTitle
.
getAnalysisId
().
intValue
()
==
2
)
{
if
(
analysisRoundExamTitle
.
getAnalysisId
().
intValue
()
==
PSA_ANALYSIS_ID
)
{
for
(
ReplyDto
replyDto
:
replyDtoList
)
{
replyDto
.
setReplayTime
(
""
);
}
...
...
@@ -244,8 +250,7 @@ public class AnalysisController {
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
examTitleReplyDetailDto
.
setReplyStatus
(
2
);
}
{
}
else
{
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
...
...
@@ -299,6 +304,27 @@ public class AnalysisController {
examTitleReplyDetailDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDetailDto
.
setReply
(
replyDto
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDetailDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
/**
* 设置回复状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
examTitleReplyDetailDto
.
setReplyStatus
(
2
);
}
else
{
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
&&
reply
!=
null
)
{
examTitleReplyDetailDto
.
setReplyStatus
(
getReplyStatus
(
analysisRoundExamTitle
.
getAnalysisId
(),
reply
.
getAnalysisRoundExamTitleId
(),
user
.
getId
()));
}
}
/**
* 设置类型
*/
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setType
(
analysis
.
getType
().
intValue
());
builder
.
setData
(
examTitleReplyDetailDto
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -521,7 +547,7 @@ public class AnalysisController {
/**
* 如果判断检测的数据中有垃圾 直接返回
*/
PicaResponse
response
=
antiSpamService
.
processString
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
content
);
PicaResponse
response
=
antiSpamService
.
processString
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
content
,
false
);
if
(!
response
.
getCode
().
equals
(
PicaResultCode
.
SUCCESS
.
code
()))
{
response
.
setData
(
""
);
return
response
;
...
...
@@ -591,7 +617,7 @@ public class AnalysisController {
*/
roundExamTitleV2Dto
.
setRoundList
(
new
ArrayList
<>());
}
else
{
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
();
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
/**
* 获取list中第一个的roundId
...
...
@@ -651,6 +677,10 @@ public class AnalysisController {
System
.
out
.
println
(
"myStar: user == null, token="
+
token
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
/**
* TODO: test,生产环境中打开,判断权限
*/
/*if (!rankingListService.isRankingInTop200(user.getId())) {
return ReturnUtil.getPicaResponse(PicaResultCode.PERMISSION_NO_ACCESS);
}
...
...
@@ -664,7 +694,7 @@ public class AnalysisController {
myStarDto
.
setDoctor
(
doctorService
.
getDoctorDtoById
(
user
.
getId
()));
myStarDto
.
setRoundList
(
new
ArrayList
<>());
if
(
roundId
==
null
)
{
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
();
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
roundId
=
roundDtoList
.
get
(
0
).
getRoundId
();
myStarDto
.
setRoundList
(
roundDtoList
);
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AntiSpamController.java
浏览文件 @
801f34a1
...
...
@@ -27,32 +27,69 @@ public class AntiSpamController {
@Autowired
AntiSpamService
antiSpamService
;
@ApiOperation
(
value
=
"
回复
"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
process
(
@RequestBody
String
content
,
@ApiOperation
(
value
=
"
内容检测
"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/
text
"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
process
Text
(
@RequestBody
String
content
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
token
)
{
if
(
token
==
null
)
{
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
picaResponse
.
setData
(
""
);
return
picaResponse
;
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
}
PICAUser
user
=
CommonUtils
.
getUserByToken
(
redisClient
,
token
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
picaResponse
.
setData
(
""
);
return
picaResponse
;
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
StringBuilder
sbContent
=
new
StringBuilder
();
/**
* type:0 不检测广告 其他: 检测广告, 默认不检测
*/
Integer
type
=
0
;
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
content
=
jsonObject
.
get
(
"content"
).
toString
();
sbContent
.
append
(
jsonObject
.
get
(
"content"
).
toString
());
type
=
(
jsonObject
.
get
(
"type"
)
!=
null
?
Integer
.
parseInt
(
jsonObject
.
get
(
"type"
).
toString
())
:
0
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"parse error: "
+
content
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
return
antiSpamService
.
processString
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
content
);
return
antiSpamService
.
processString
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
sbContent
.
toString
(),
type
!=
0
);
}
@ApiOperation
(
value
=
"图片检测"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/image"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
processImage
(
@RequestBody
String
content
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
token
)
{
if
(
token
==
null
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
}
PICAUser
user
=
CommonUtils
.
getUserByToken
(
redisClient
,
token
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
StringBuilder
sbContent
=
new
StringBuilder
();
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
sbContent
.
append
(
jsonObject
.
get
(
"content"
).
toString
());
}
catch
(
Exception
e
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
if
(!
antiSpamService
.
processImageContent
(
user
!=
null
?
user
.
getId
()
:
0
,
sysCode
,
sbContent
.
toString
()))
{
return
ReturnUtil
.
getPicaResponse
(
"400002"
,
"图片包含违禁内容,请修改后重新输入"
,
""
);
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/AntiSpamService.java
浏览文件 @
801f34a1
...
...
@@ -7,7 +7,15 @@ import com.pica.cloud.foundation.entity.PicaResponse;
* @date 2018/8/27 14:38
*/
public
interface
AntiSpamService
{
PicaResponse
processString
(
Integer
userId
,
String
sysCode
,
String
content
);
/**
* 解析字符串
* @param userId
* @param sysCode
* @param content
* @param isAdFilterOpen 是否过滤广告
* @return
*/
PicaResponse
processString
(
Integer
userId
,
String
sysCode
,
String
content
,
boolean
isAdFilterOpen
);
boolean
processImageContent
(
Integer
userId
,
String
sysCode
,
String
content
);
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/CHCAnalysisService.java
浏览文件 @
801f34a1
...
...
@@ -168,9 +168,10 @@ public interface CHCAnalysisService {
/**
* 获取所有的历史轮详情
* @param ananlysisId
* @return
*/
List
<
AnalysisRoundDto
>
getCHCHistoryRound
();
List
<
AnalysisRoundDto
>
getCHCHistoryRound
(
Integer
analysisId
);
/**
* 获取某一轮的最多得票数
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/AntiSpamServiceImpl.java
浏览文件 @
801f34a1
...
...
@@ -37,7 +37,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
private
static
HttpClient
httpClient
=
HttpClient4Utils
.
createHttpClient
(
100
,
20
,
2000
,
2000
,
2000
);
private
static
HttpClient
httpClientImage
=
HttpClient4Utils
.
createHttpClient
(
100
,
20
,
10000
,
2000
,
2000
);
@Override
public
PicaResponse
processString
(
Integer
userId
,
String
sysCode
,
String
content
)
{
public
PicaResponse
processString
(
Integer
userId
,
String
sysCode
,
String
content
,
boolean
isAdFilterOpen
)
{
/**
* 过滤图片
*/
...
...
@@ -51,7 +51,12 @@ public class AntiSpamServiceImpl implements AntiSpamService {
* 1. 设置公共参数
*/
params
.
put
(
"secretId"
,
properties
.
getNeteaseAntispamSecretId
());
params
.
put
(
"businessId"
,
properties
.
getNeteaseAntispamTextBusinessId
());
if
(!
isAdFilterOpen
)
params
.
put
(
"businessId"
,
properties
.
getNeteaseAntispamTextBusinessId
());
else
params
.
put
(
"businessId"
,
properties
.
getNeteaseAntispamTextAdBusinessId
());
params
.
put
(
"version"
,
"v3.1"
);
params
.
put
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
params
.
put
(
"nonce"
,
String
.
valueOf
(
new
Random
().
nextInt
()));
...
...
@@ -121,8 +126,16 @@ public class AntiSpamServiceImpl implements AntiSpamService {
else
if
(
label
==
600
)
msg
=
"输入内容包含谩骂词汇,请修改后重新输入"
;
else
if
(
label
==
700
)
msg
=
"输入内容包含灌水词汇,请修改后重新输入"
;
insertRecord
(
userId
,
sysCode
,
content
,
response
,
(
byte
)
action
,
label
,
detailsObject
.
getAsString
());
return
ReturnUtil
.
getPicaResponse
(
"400002"
,
msg
,
""
);
StringBuilder
hint
=
new
StringBuilder
();
for
(
JsonElement
eleHint
:
hintArray
)
{
hint
.
append
(
eleHint
.
getAsString
()).
append
(
","
);
}
if
(
hint
.
length
()
>
0
)
{
hint
.
deleteCharAt
(
hint
.
length
()
-
1
);
}
insertRecord
(
userId
,
sysCode
,
content
,
response
,
(
byte
)
action
,
label
,
hint
.
toString
());
return
ReturnUtil
.
getPicaResponse
(
"400002"
,
msg
,
hint
.
toString
());
}
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/CHCAnalysisServiceImpl.java
浏览文件 @
801f34a1
...
...
@@ -519,13 +519,13 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
}
@Override
public
List
<
AnalysisRoundDto
>
getCHCHistoryRound
()
{
public
List
<
AnalysisRoundDto
>
getCHCHistoryRound
(
Integer
analysisId
)
{
List
<
AnalysisRound
>
roundList
=
new
ArrayList
<>();
/**
* TODO: 需要前端传入id
*/
roundList
=
analysisRoundMapper
.
selectHistoryRoundListById
(
1
);
roundList
=
analysisRoundMapper
.
selectHistoryRoundListById
(
analysisId
);
List
<
AnalysisRoundDto
>
roundDtoList
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录