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
提交
25043b4d
提交
25043b4d
编写于
8月 28, 2018
作者:
minghao.wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: 加入replyStatus参数,插入回复记录完成
上级
da0b51b8
变更
10
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
241 行增加
和
9 行删除
+241
-9
ExamTitleReplyDetailDto.java
...ine/exam/analysis.common/dto/ExamTitleReplyDetailDto.java
+13
-0
ExamTitleReplyDto.java
...ud/online/exam/analysis.common/dto/ExamTitleReplyDto.java
+1
-1
AnalysisController.java
...e/exam/analysis/server/controller/AnalysisController.java
+56
-6
CHCAnalysisMapper.java
...online/exam/analysis/server/mapper/CHCAnalysisMapper.java
+2
-0
ReplyMapper.java
...cloud/online/exam/analysis/server/mapper/ReplyMapper.java
+4
-0
CHCAnalysisService.java
...line/exam/analysis/server/service/CHCAnalysisService.java
+22
-0
AntiSpamServiceImpl.java
...xam/analysis/server/service/impl/AntiSpamServiceImpl.java
+32
-2
CHCAnalysisServiceImpl.java
.../analysis/server/service/impl/CHCAnalysisServiceImpl.java
+81
-0
CHCAnalysisMapper.xml
server/src/main/resources/mybatis/CHCAnalysisMapper.xml
+12
-0
ReplyMapper.xml
server/src/main/resources/mybatis/ReplyMapper.xml
+18
-0
未找到文件。
common/src/main/java/com/pica/cloud/online/exam/analysis.common/dto/ExamTitleReplyDetailDto.java
浏览文件 @
25043b4d
...
...
@@ -14,6 +14,11 @@ public class ExamTitleReplyDetailDto {
private
ReplyDto
reply
;
/**
* 是否允许回复 0: 否 1: 填写 2: 编辑
*/
private
Integer
replyStatus
;
public
Integer
getAnalysisId
()
{
return
analysisId
;
}
...
...
@@ -45,4 +50,12 @@ public class ExamTitleReplyDetailDto {
public
void
setReply
(
ReplyDto
reply
)
{
this
.
reply
=
reply
;
}
public
Integer
getReplyStatus
()
{
return
replyStatus
;
}
public
void
setReplyStatus
(
Integer
replyStatus
)
{
this
.
replyStatus
=
replyStatus
;
}
}
common/src/main/java/com/pica/cloud/online/exam/analysis.common/dto/ExamTitleReplyDto.java
浏览文件 @
25043b4d
...
...
@@ -17,7 +17,7 @@ public class ExamTitleReplyDto {
private
List
<
ReplyDto
>
replyList
;
/**
* 是否允许回复 0: 否 1:
是
* 是否允许回复 0: 否 1:
填写 2: 编辑
*/
private
Integer
replyStatus
;
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AnalysisController.java
浏览文件 @
25043b4d
...
...
@@ -16,6 +16,7 @@ import com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService;
import
com.pica.cloud.online.exam.analysis.server.service.DoctorService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javassist.bytecode.ExceptionsAttribute
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -72,6 +73,30 @@ public class AnalysisController {
return
builder
.
build
();
}
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/psaActivityDetail"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
CHCAnalysisDto
>
getPSAActivityDetail
(
@RequestParam
(
required
=
false
)
Integer
id
)
{
PicaResponse
.
Builder
<
CHCAnalysisDto
>
builder
=
new
PicaResponse
.
Builder
<>();
/**
* 如果不传活动id进来,活动id就用1
*/
id
=
(
id
==
null
?
2
:
id
);
try
{
CHCAnalysisDto
analysisDto
=
analysisService
.
getPSAAnalysisById
(
id
);
List
<
AnalysisRoundDto
>
roundList
=
analysisService
.
getRoundListByAnalysisId
(
id
);
analysisDto
.
setRoundList
(
roundList
);
builder
.
setData
(
analysisDto
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_INNER_ERROR
);
}
return
builder
.
build
();
}
@ApiOperation
(
value
=
"获取某一轮的题目"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/roundDetail/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
RoundExamTitleDto
>
getRoundDetail
(
@PathVariable
(
"roundId"
)
Integer
roundId
)
{
...
...
@@ -94,7 +119,7 @@ public class AnalysisController {
@ApiOperation
(
value
=
"获取某一道题目的回复列表"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/replyList/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDto
>
getReplyList
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
@Request
Param
(
required
=
false
)
String
token
)
{
@Request
Header
(
required
=
false
)
String
token
)
{
PICAUser
user
=
null
;
...
...
@@ -116,6 +141,15 @@ public class AnalysisController {
examTitleReplyDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDto
.
setReplyList
(
replyDtoList
);
if
(
user
==
null
||
user
.
getId
()
==
0
)
{
examTitleReplyDto
.
setReplyStatus
(
0
);
}
else
{
/**
* 判断权限
*/
examTitleReplyDto
.
setReplyStatus
(
analysisService
.
getReplyStatus
(
examTitleId
,
user
.
getId
()));
}
builder
.
setData
(
examTitleReplyDto
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -212,8 +246,9 @@ public class AnalysisController {
PICAUser
user
=
CommonUtils
.
getUserByToken
(
redisClient
,
token
);
if
(
user
==
null
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_INVALID_TOKEN
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
System
.
out
.
println
(
"cancelStar: user == null, token="
+
token
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
System
.
out
.
println
(
"cancelStar: replyid="
+
replyId
.
toString
()
+
" token="
+
token
);
...
...
@@ -306,11 +341,26 @@ public class AnalysisController {
PICAUser
user
=
CommonUtils
.
getUserByToken
(
redisClient
,
token
);
if
(
user
==
null
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_INVALID_TOKEN
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
System
.
out
.
println
(
"reply: user == null, token="
+
token
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
antiSpamService
.
processString
(
content
);
/**
* 如果判断检测的数据中有垃圾 直接返回
*/
PicaResponse
response
=
antiSpamService
.
processString
(
content
);
if
(!
response
.
getCode
().
equals
(
PicaResultCode
.
SUCCESS
.
code
()))
return
response
;
/**
* 插入数据库
*/
try
{
analysisService
.
insertReply
(
examTitleId
,
content
,
user
.
getId
());
}
catch
(
Exception
e
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
INTERFACE_INVOKE_EXCEPTION
);
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/mapper/CHCAnalysisMapper.java
浏览文件 @
25043b4d
...
...
@@ -11,6 +11,8 @@ public interface CHCAnalysisMapper {
CHCAnalysis
selectByPrimaryKey
(
Integer
id
);
CHCAnalysis
selectPSAByPrimaryKey
(
Integer
id
);
int
updateByPrimaryKeySelective
(
CHCAnalysis
record
);
int
updateByPrimaryKey
(
CHCAnalysis
record
);
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/mapper/ReplyMapper.java
浏览文件 @
25043b4d
...
...
@@ -19,5 +19,9 @@ public interface ReplyMapper {
int
selectReplyCountByAnalysisRoundExamTitleId
(
Integer
analysisRoundExamTitleId
);
int
selectReplyCountByRecord
(
Reply
record
);
Reply
selectReplyByRecord
(
Reply
record
);
List
<
Reply
>
selectReplyListByAnalysisRoundExamTitleId
(
Integer
analysisRoundExamTitleId
);
}
\ No newline at end of file
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/CHCAnalysisService.java
浏览文件 @
25043b4d
...
...
@@ -18,6 +18,12 @@ public interface CHCAnalysisService {
*/
CHCAnalysisDto
getCHCAnalysisById
(
Integer
analysisId
);
/**
* 根据活动id获取活动详情
* @param analysisId
* @return
*/
CHCAnalysisDto
getPSAAnalysisById
(
Integer
analysisId
);
/**
* 根据活动id获取活动的轮数
...
...
@@ -110,4 +116,20 @@ public interface CHCAnalysisService {
*/
Integer
removeStarRecord
(
Integer
replyId
,
Integer
userId
);
/**
* 增加解析
* @param examTitleId
* @param content
* @param userId
* @return
*/
Integer
insertReply
(
Integer
examTitleId
,
String
content
,
Integer
userId
);
/**
* 获取我的评论状态
* @param examTitleId
* @param userId
* @return
*/
Integer
getReplyStatus
(
Integer
examTitleId
,
Integer
userId
);
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/AntiSpamServiceImpl.java
浏览文件 @
25043b4d
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
service
.
impl
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
...
...
@@ -46,6 +47,7 @@ public class AntiSpamServiceImpl implements AntiSpamService {
/**
* 2. 设置私有参数
*/
params
.
put
(
"dataId"
,
"ebfcad1c-pica-490c-b4de-e784c2691768"
);
params
.
put
(
"content"
,
content
);
/**
...
...
@@ -63,6 +65,8 @@ public class AntiSpamServiceImpl implements AntiSpamService {
*/
String
response
=
HttpClient4Utils
.
sendPost
(
httpClient
,
properties
.
getNeteaseAntispamTextApiUrl
(),
params
,
Consts
.
UTF_8
);
System
.
out
.
println
(
"content:"
+
content
+
" response="
+
response
);
/**
* 5. 解析返回值
*/
...
...
@@ -70,11 +74,37 @@ public class AntiSpamServiceImpl implements AntiSpamService {
int
code
=
jObject
.
get
(
"code"
).
getAsInt
();
String
msg
=
jObject
.
get
(
"msg"
).
getAsString
();
if
(
code
==
200
)
{
JsonObject
resultObject
=
jObject
.
getAsJsonObject
(
"result"
);
int
action
=
resultObject
.
get
(
"action"
).
getAsInt
();
/**
* label: 100 色情
* label: 200 广告
* label: 400 违禁
* label: 500 涉政
* label: 600 谩骂
* label: 700 灌水
*/
JsonArray
labelArray
=
resultObject
.
getAsJsonArray
(
"labels"
);
/**
* action: 0 通过
* action: 1 嫌疑
* action: 2 不通过
*/
if
(
action
==
0
)
{
}
else
{
/**
* TODO: 可以进一步处理 显示信息被过滤原因
*/
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
DATA_IS_WRONG
);
}
}
else
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
DATA_IS_WRONG
);
return
ReturnUtil
.
getPicaResponse
(
jObject
.
get
(
"code"
).
getAsString
(),
msg
);
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
DATA_IS_WRONG
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/CHCAnalysisServiceImpl.java
浏览文件 @
25043b4d
...
...
@@ -71,6 +71,31 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
analysisDto
;
}
@Override
public
CHCAnalysisDto
getPSAAnalysisById
(
Integer
analysisId
)
{
CHCAnalysis
analysis
=
analysisMapper
.
selectPSAByPrimaryKey
(
analysisId
);
if
(
null
==
analysis
)
{
return
null
;
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
CHCAnalysisDto
analysisDto
=
new
CHCAnalysisDto
();
analysisDto
.
setId
(
analysis
.
getId
());
analysisDto
.
setName
(
analysis
.
getAnalysisName
());
analysisDto
.
setMainTitle
(
analysis
.
getMainTitle
());
analysisDto
.
setSubTitle
(
analysis
.
getSubTitle
());
analysisDto
.
setIntro
(
analysis
.
getIntro
());
analysisDto
.
setStartTime
(
sdf
.
format
(
analysis
.
getStartTime
()));
analysisDto
.
setEndTime
(
sdf
.
format
(
analysis
.
getEndTime
()));
analysisDto
.
setLogoUrl
(
analysis
.
getLogoUrl
());
analysisDto
.
setPrizeUrl
(
analysis
.
getPrizeUrl
());
analysisDto
.
setAuthUser
(
analysis
.
getAuthUser
());
analysisDto
.
setRule
(
analysis
.
getRule
());
return
analysisDto
;
}
@Override
public
List
<
AnalysisRoundDto
>
getRoundListByAnalysisId
(
Integer
analysisId
)
{
List
<
AnalysisRound
>
roundList
=
analysisRoundMapper
.
selectRoundListById
(
analysisId
);
...
...
@@ -357,4 +382,60 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
this
.
getExamTitleDtoById
(
roundExamTitleList
.
get
(
idx
).
getId
());
}
@Override
public
Integer
insertReply
(
Integer
examTitleId
,
String
content
,
Integer
userId
)
{
/**
* 找到我是否已经回复过,如果回复过就编辑,没有就新建
*/
Reply
reply
=
new
Reply
();
reply
.
setAnalysisRoundExamTitleId
(
examTitleId
);
reply
.
setUserId
(
userId
);
Integer
myReplyCount
=
replyMapper
.
selectReplyCountByRecord
(
reply
);
if
(
myReplyCount
==
0
)
{
Integer
replyCount
=
replyMapper
.
selectReplyCountByAnalysisRoundExamTitleId
(
examTitleId
);
reply
.
setContent
(
content
);
reply
.
setReplyLevel
((
byte
)
1
);
reply
.
setSeqNo
(
replyCount
+
1
);
reply
.
setStarCount
(
0
);
reply
.
setCreatedId
(
userId
);
reply
.
setCreatedTime
(
new
Date
());
reply
.
setModifiedId
(
userId
);
reply
.
setModifiedTime
(
new
Date
());
reply
.
setIsDeleted
(
false
);
return
replyMapper
.
insert
(
reply
);
}
else
{
Reply
record
=
replyMapper
.
selectReplyByRecord
(
reply
);
record
.
setContent
(
content
);
record
.
setModifiedTime
(
new
Date
());
return
replyMapper
.
updateByPrimaryKey
(
record
);
}
}
@Override
public
Integer
getReplyStatus
(
Integer
examTitleId
,
Integer
userId
)
{
Reply
reply
=
new
Reply
();
reply
.
setAnalysisRoundExamTitleId
(
examTitleId
);
reply
.
setUserId
(
userId
);
Integer
myReplyCount
=
replyMapper
.
selectReplyCountByRecord
(
reply
);
if
(
myReplyCount
==
0
)
{
/**
* 未回复过
*/
return
1
;
}
/**
* 已回复过
*/
return
2
;
}
}
server/src/main/resources/mybatis/CHCAnalysisMapper.xml
浏览文件 @
25043b4d
...
...
@@ -31,7 +31,19 @@
<include
refid=
"Base_Column_List"
/>
from p_chc_analysis
where id = #{id,jdbcType=INTEGER}
and type = 1
and is_deleted = 0
</select>
<select
id=
"selectPSAByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from p_chc_analysis
where id = #{id,jdbcType=INTEGER}
and type = 2
and is_deleted = 0
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from p_chc_analysis
where id = #{id,jdbcType=INTEGER}
...
...
server/src/main/resources/mybatis/ReplyMapper.xml
浏览文件 @
25043b4d
...
...
@@ -36,6 +36,24 @@
and is_deleted = 0
</select>
<select
id=
"selectReplyCountByRecord"
resultType=
"java.lang.Integer"
parameterType=
"com.pica.cloud.online.exam.analysis.server.entity.Reply"
>
select
count(1)
from p_reply
where analysis_round_exam_title_id = #{analysisRoundExamTitleId,jdbcType=INTEGER}
and user_id = #{userId,jdbcType=INTEGER}
and is_deleted = 0
</select>
<select
id=
"selectReplyByRecord"
resultMap=
"BaseResultMap"
parameterType=
"com.pica.cloud.online.exam.analysis.server.entity.Reply"
>
select
<include
refid=
"Base_Column_List"
/>
from p_reply
where analysis_round_exam_title_id = #{analysisRoundExamTitleId,jdbcType=INTEGER}
and user_id = #{userId,jdbcType=INTEGER}
and is_deleted = 0
</select>
<select
id=
"selectReplyListByAnalysisRoundExamTitleId"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录