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
提交
e4fec645
提交
e4fec645
编写于
12月 28, 2018
作者:
minghao.wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: controller->service
上级
901372ef
流水线
#3083
已通过 于阶段
in 10 second
变更
5
流水线
1
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
501 行增加
和
863 行删除
+501
-863
AnalysisController.java
...e/exam/analysis/server/controller/AnalysisController.java
+38
-576
AntiSpamController.java
...e/exam/analysis/server/controller/AntiSpamController.java
+16
-45
CHCAnalysisService.java
...line/exam/analysis/server/service/CHCAnalysisService.java
+55
-141
CHCAnalysisServiceImpl.java
.../analysis/server/service/impl/CHCAnalysisServiceImpl.java
+391
-100
bootstrap-dev.properties
server/src/main/resources/bootstrap-dev.properties
+1
-1
未找到文件。
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AnalysisController.java
浏览文件 @
e4fec645
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
controller
;
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dianping.cat.Cat
;
import
com.dianping.cat.message.Transaction
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.utils.annotation.LoginPermission
;
import
com.pica.cloud.foundation.utils.annotation.LoginPermission
;
import
com.pica.cloud.foundation.utils.controller.BaseController
;
import
com.pica.cloud.foundation.utils.controller.BaseController
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.online.exam.analysis.common.constants.CommonConstants
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.common.util.ReturnUtil
;
import
com.pica.cloud.online.exam.analysis.common.util.ReturnUtil
;
import
com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.online.exam.analysis.server.entity.*
;
import
com.pica.cloud.online.exam.analysis.server.service.AntiSpamService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCRankingListService
;
import
com.pica.cloud.online.exam.analysis.server.service.DoctorService
;
import
com.pica.cloud.online.exam.analysis.server.service.DoctorService
;
import
com.pica.cloud.online.exam.analysis.server.utils.DateUtils
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Optional
;
import
javax.ws.rs.Path
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
/**
* @author wuminghao
* @author wuminghao
...
@@ -40,7 +27,6 @@ import java.util.List;
...
@@ -40,7 +27,6 @@ import java.util.List;
@RestController
@RestController
@RequestMapping
(
"/"
)
@RequestMapping
(
"/"
)
public
class
AnalysisController
extends
BaseController
{
public
class
AnalysisController
extends
BaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
AnalysisController
.
class
);
@Qualifier
(
"cacheMigrateClient"
)
@Qualifier
(
"cacheMigrateClient"
)
@Autowired
@Autowired
...
@@ -49,670 +35,146 @@ public class AnalysisController extends BaseController {
...
@@ -49,670 +35,146 @@ public class AnalysisController extends BaseController {
@Autowired
@Autowired
private
CHCAnalysisService
analysisService
;
private
CHCAnalysisService
analysisService
;
@Autowired
@Autowired
private
DoctorService
doctorService
;
@Autowired
private
AntiSpamService
antiSpamService
;
@Autowired
private
CHCRankingListService
rankingListService
;
@Autowired
private
PropertiesConfiguration
propertiesConfiguration
;
private
PropertiesConfiguration
propertiesConfiguration
;
/**
* TODO: chc错题解析活动和psa的活动id 需要前端传入
*/
static
final
Integer
CHC_ANALYSIS_ID
=
1
;
static
final
Integer
CHC_ANALYSIS_ID
=
1
;
static
final
Integer
PSA_ANALYSIS_ID
=
2
;
static
final
Integer
PSA_ANALYSIS_ID
=
2
;
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/config"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/config"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
String
config
()
{
public
String
config
()
{
return
propertiesConfiguration
.
toString
();
return
propertiesConfiguration
.
toString
();
}
}
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
{
"/activityDetail"
,
"/activityDetail/{id}"
},
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
{
"/activityDetail"
,
"/activityDetail/{id}"
},
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
CHCAnalysisDto
>
getActivityDetail
(
@PathVariable
(
required
=
false
)
Integer
id
,
public
PicaResponse
<
CHCAnalysisDto
>
getActivityDetail
(
@PathVariable
(
required
=
false
)
Integer
id
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
PicaResponse
.
Builder
<
CHCAnalysisDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
CHCAnalysisDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
PicaUser
user
=
null
;
try
{
try
{
user
=
fetchPicaUser
();
user
=
fetchPicaUser
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
builder
.
setData
(
analysisService
.
getActivityDetail
(
id
==
null
?
CHC_ANALYSIS_ID
:
id
,
user
));
builder
.
setData
(
analysisService
.
get
CHC
ActivityDetail
(
id
==
null
?
CHC_ANALYSIS_ID
:
id
,
user
));
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"获取活动详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/psaActivityDetail"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/psaActivityDetail"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
CHCAnalysisDto
>
getPSAActivityDetail
(
@RequestParam
(
required
=
false
)
Integer
id
)
{
public
PicaResponse
<
CHCAnalysisDto
>
getPSAActivityDetail
(
@RequestParam
(
required
=
false
)
Integer
id
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/psaActivityDetail"
);
PicaResponse
.
Builder
<
CHCAnalysisDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
CHCAnalysisDto
>
builder
=
new
PicaResponse
.
Builder
<>();
/**
builder
.
setData
(
analysisService
.
getPSAActivityDetail
(
id
==
null
?
PSA_ANALYSIS_ID
:
id
));
* 如果不传活动id进来,活动id就用1
*/
id
=
(
id
==
null
?
PSA_ANALYSIS_ID
:
id
);
try
{
CHCAnalysisDto
analysisDto
=
analysisService
.
getPSAAnalysisDtoById
(
id
);
List
<
AnalysisRoundDto
>
roundList
=
analysisService
.
getRoundListByAnalysisId
(
id
);
analysisDto
.
setRoundList
(
roundList
);
builder
.
setData
(
analysisDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"getPSAActivityDetail"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
t
.
complete
();
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"获取某一轮的题目"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/roundDetail/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/roundDetail/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
RoundExamTitleDto
>
getRoundDetail
(
@PathVariable
(
"roundId"
)
Integer
roundId
)
{
public
PicaResponse
<
RoundExamTitleDto
>
getRoundDetail
(
@PathVariable
(
"roundId"
)
Integer
roundId
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/roundDetail"
);
logger
.
info
(
"roundDetail: roundId"
+
roundId
);
PicaResponse
.
Builder
<
RoundExamTitleDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
RoundExamTitleDto
>
builder
=
new
PicaResponse
.
Builder
<>();
builder
.
setData
(
analysisService
.
getRoundDetail
(
roundId
));
try
{
RoundExamTitleDto
roundExamTitleDto
=
analysisService
.
getRoundExamTitleDtoById
(
roundId
);
List
<
ExamTitleDto
>
examTitleDtoList
=
analysisService
.
getExamTitleListByRoundId
(
roundId
);
roundExamTitleDto
.
setExamTitleList
(
examTitleDtoList
);
builder
.
setData
(
roundExamTitleDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"getRoundDetail"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
t
.
complete
();
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"获取某一道题目的回复列表"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/replyList/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/replyList/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDto
>
getReplyList
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
public
PicaResponse
<
ExamTitleReplyDto
>
getReplyList
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/replyList"
);
PicaUser
user
=
fetchPicaUser
();
PicaResponse
.
Builder
<
ExamTitleReplyDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
ExamTitleReplyDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
try
{
try
{
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisService
.
getAnanlysisRoundExamTitleById
(
examTitleId
);
user
=
fetchPicaUser
();
ExamTitleReplyDto
examTitleReplyDto
=
new
ExamTitleReplyDto
();
ExamTitleDto
examTitleDto
=
analysisService
.
getExamTitleDtoById
(
examTitleId
);
List
<
ReplyDto
>
replyDtoList
=
analysisService
.
getReplyListDtoByExamTitleId
(
examTitleId
,
user
!=
null
?
user
.
getId
()
:
0
);
/**
* TODO: 如果是PSA 删除时间显示
*/
if
(
analysisRoundExamTitle
.
getAnalysisId
().
intValue
()
==
PSA_ANALYSIS_ID
)
{
for
(
ReplyDto
replyDto
:
replyDtoList
)
{
replyDto
.
setReplayTime
(
""
);
}
}
examTitleReplyDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDto
.
setReplyList
(
replyDtoList
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
/**
* 设置回复状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
examTitleReplyDto
.
setReplyStatus
(
0
);
}
else
{
examTitleReplyDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDto
.
setReplyStatus
(
getReplyStatus
(
analysisRoundExamTitle
.
getAnalysisId
(),
examTitleId
,
user
.
getId
()));
}
}
/**
* 设置类型
*/
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDto
.
setType
(
analysis
.
getType
().
intValue
());
builder
.
setData
(
examTitleReplyDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"getReplyList"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
t
.
complete
(
);
builder
.
setData
(
analysisService
.
getReplyListByExamTitleId
(
examTitleId
,
user
)
);
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"查看回复详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/replyDetail/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/replyDetail/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDetailDto
>
getReplyDetail
(
@PathVariable
(
"replyId"
)
Integer
replyId
,
public
PicaResponse
<
ExamTitleReplyDetailDto
>
getReplyDetail
(
@PathVariable
(
"replyId"
)
Integer
replyId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/replyDetail"
);
PicaUser
user
=
fetchPicaUser
();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
try
{
try
{
ExamTitleReplyDetailDto
examTitleReplyDetailDto
=
new
ExamTitleReplyDetailDto
();
user
=
fetchPicaUser
();
Reply
reply
=
analysisService
.
getReplyById
(
replyId
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisService
.
getAnanlysisRoundExamTitleById
(
reply
.
getAnalysisRoundExamTitleId
());
ExamTitleDto
examTitleDto
=
analysisService
.
getExamTitleDtoById
(
reply
.
getAnalysisRoundExamTitleId
());
ReplyDto
replyDto
=
analysisService
.
getReplyDtoByReply
(
reply
,
user
!=
null
?
user
.
getId
()
:
0
);
examTitleReplyDetailDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
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
(
0
);
}
else
{
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDetailDto
.
setReplyStatus
(
getReplyStatus
(
analysisRoundExamTitle
.
getAnalysisId
(),
reply
.
getAnalysisRoundExamTitleId
(),
user
.
getId
()));
}
}
/**
* 设置类型
*/
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setType
(
analysis
.
getType
().
intValue
());
builder
.
setData
(
examTitleReplyDetailDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"getReplyDetail"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
t
.
complete
(
);
builder
.
setData
(
analysisService
.
getReplyDetailByReplyId
(
replyId
,
user
)
);
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"查看回复详情"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/replyDetailByExamTitleId/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/replyDetailByExamTitleId/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDetailDto
>
getReplyDetailByExamTitleId
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
public
PicaResponse
<
ExamTitleReplyDetailDto
>
getReplyDetailByExamTitleId
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/replyDetailByExamTitleId"
);
logger
.
info
(
"replyDetailByExamTitleId: examTitleId == "
+
examTitleId
.
toString
()
+
", token="
+
token
);
PicaUser
user
=
fetchPicaUser
();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
try
{
try
{
ExamTitleReplyDetailDto
examTitleReplyDetailDto
=
new
ExamTitleReplyDetailDto
();
user
=
fetchPicaUser
();
Reply
reply
=
analysisService
.
getReplyByExamTitleId
(
examTitleId
,
user
!=
null
?
user
.
getId
()
:
0
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisService
.
getAnanlysisRoundExamTitleById
(
examTitleId
);
ExamTitleDto
examTitleDto
=
analysisService
.
getExamTitleDtoById
(
examTitleId
);
ReplyDto
replyDto
=
new
ReplyDto
();
if
(
null
!=
reply
)
{
replyDto
=
analysisService
.
getReplyDtoByReply
(
reply
,
user
!=
null
?
user
.
getId
()
:
0
);
}
else
{
replyDto
.
setContent
(
""
);
}
examTitleReplyDetailDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
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
(
0
);
}
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
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"getReplyDetailByExamTitleId"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
t
.
complete
(
);
builder
.
setData
(
analysisService
.
getReplyDetailByExamTitleId
(
examTitleId
,
user
)
);
return
builder
.
build
();
return
builder
.
build
();
}
}
@LoginPermission
@LoginPermission
@ApiOperation
(
value
=
"点赞"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/starReply/{replyId}/analysis/{analysisId}/round/{roundId}/examTitle/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/starReply/{replyId}/analysis/{analysisId}/round/{roundId}/examTitle/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
starReply
(
@PathVariable
(
"analysisId"
)
Integer
analysisId
,
@PathVariable
(
"roundId"
)
Integer
roundId
,
public
PicaResponse
starReply
(
@PathVariable
(
"analysisId"
)
Integer
analysisId
,
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
@PathVariable
(
"replyId"
)
Integer
replyId
,
@PathVariable
(
"roundId"
)
Integer
roundId
,
@RequestHeader
(
required
=
false
)
String
token
)
{
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
@PathVariable
(
"replyId"
)
Integer
replyId
)
{
PicaUser
user
=
fetchPicaUser
();
return
analysisService
.
starReply
(
fetchPicaUser
(),
analysisId
,
roundId
,
examTitleId
,
replyId
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
logger
.
info
(
"starrecord: user == null, token="
+
token
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
Doctor
doctor
=
doctorService
.
getDoctorById
(
user
.
getId
());
if
(
doctor
==
null
)
{
logger
.
info
(
"starrecord: doctor == null, userid="
+
user
.
getId
().
toString
());
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_INVALID_TOKEN
);
}
/**
* 未认证用户直接返回
*/
if
(!(
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_3
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_6
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_7
)
))
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
INTERFACE_FORBID_VISIT
);
}
logger
.
info
(
"starrecord: replyid="
+
replyId
.
toString
()
+
" token="
+
token
+
" roundId="
+
roundId
+
" examTitleId="
+
examTitleId
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
roundId
);
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
return
ReturnUtil
.
getPicaResponse
(
"500002"
,
"本期活动已结束"
);
}
if
(
0
!=
analysisService
.
insertStarRecord
(
analysisId
,
roundId
,
examTitleId
,
replyId
,
user
.
getId
()))
{
/**
* 已经点过赞
*/
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
DATA_ALREADY_EXISTED
);
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
}
@LoginPermission
@LoginPermission
@ApiOperation
(
value
=
"取消点赞"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/cancelStar/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/cancelStar/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
cancelStar
(
@PathVariable
(
"replyId"
)
Integer
replyId
,
public
PicaResponse
cancelStar
(
@PathVariable
(
"replyId"
)
Integer
replyId
,
@RequestHeader
(
required
=
false
)
String
token
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
PicaUser
user
=
fetchPicaUser
();
if
(
0
!=
analysisService
.
removeStarRecord
(
replyId
,
fetchPicaUser
()))
{
logger
.
info
(
"cancelStar: replyid="
+
replyId
.
toString
()
+
" token="
+
token
);
if
(
0
!=
analysisService
.
removeStarRecord
(
replyId
,
user
.
getId
()))
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
RESULE_DATA_NONE
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
RESULE_DATA_NONE
);
}
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
}
@ApiOperation
(
value
=
"获取某一道题目的下一道题"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/nextExamTitle/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/nextExamTitle/{examTitleId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDto
>
nextReplyList
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
public
PicaResponse
<
ExamTitleReplyDto
>
nextReplyList
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/nextExamTitle"
);
PicaUser
user
=
fetchPicaUser
();
PicaResponse
.
Builder
<
ExamTitleReplyDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
ExamTitleReplyDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
try
{
try
{
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisService
.
getAnanlysisRoundExamTitleById
(
examTitleId
);
user
=
fetchPicaUser
();
ExamTitleReplyDto
examTitleReplyDto
=
new
ExamTitleReplyDto
();
ExamTitleDto
examTitleDto
=
analysisService
.
getNextExamTitleDtoById
(
analysisRoundExamTitle
.
getRoundId
(),
examTitleId
);
List
<
ReplyDto
>
replyDtoList
=
analysisService
.
getReplyListDtoByExamTitleId
(
examTitleDto
.
getExamTitleId
(),
user
!=
null
?
user
.
getId
()
:
0
);
examTitleReplyDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDto
.
setReplyList
(
replyDtoList
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
/**
* 设置回复状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
examTitleReplyDto
.
setReplyStatus
(
0
);
}
else
{
examTitleReplyDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDto
.
setReplyStatus
(
getReplyStatus
(
analysisRoundExamTitle
.
getAnalysisId
(),
examTitleId
,
user
.
getId
()));
}
}
/**
* 设置类型
*/
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDto
.
setType
(
analysis
.
getType
().
intValue
());
builder
.
setData
(
examTitleReplyDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"nextReplyList"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
t
.
complete
(
);
builder
.
setData
(
analysisService
.
getNextReplyListByExamTitleId
(
examTitleId
,
user
)
);
return
builder
.
build
();
return
builder
.
build
();
}
}
@ApiOperation
(
value
=
"获取某一道题目的下一道题"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/nextReply/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/nextReply/{replyId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
ExamTitleReplyDto
>
nextReplyDetail
(
@PathVariable
(
"replyId"
)
Integer
replyId
,
public
PicaResponse
<
ExamTitleReplyDetailDto
>
nextReplyDetail
(
@PathVariable
(
"replyId"
)
Integer
replyId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/nextReply"
);
PicaUser
user
=
fetchPicaUser
();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
ExamTitleReplyDetailDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaUser
user
=
null
;
try
{
try
{
ExamTitleReplyDetailDto
examTitleReplyDetailDto
=
new
ExamTitleReplyDetailDto
();
user
=
fetchPicaUser
();
Reply
reply
=
analysisService
.
getNextReplyById
(
replyId
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisService
.
getAnanlysisRoundExamTitleById
(
reply
.
getAnalysisRoundExamTitleId
());
ExamTitleDto
examTitleDto
=
analysisService
.
getExamTitleDtoById
(
reply
.
getAnalysisRoundExamTitleId
());
ReplyDto
replyDto
=
analysisService
.
getReplyDtoByReply
(
reply
,
user
!=
null
?
user
.
getId
()
:
0
);
examTitleReplyDetailDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
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
(
0
);
}
else
{
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDetailDto
.
setReplyStatus
(
getReplyStatus
(
analysisRoundExamTitle
.
getAnalysisId
(),
reply
.
getAnalysisRoundExamTitleId
(),
user
.
getId
()));
}
}
/**
* 设置类型
*/
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setType
(
analysis
.
getType
().
intValue
());
builder
.
setData
(
examTitleReplyDetailDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"nextReplyDetail"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
}
t
.
complete
(
);
builder
.
setData
(
analysisService
.
getNextReplyDetailByReplyId
(
replyId
,
user
)
);
return
builder
.
build
();
return
builder
.
build
();
}
}
@LoginPermission
@LoginPermission
@ApiOperation
(
value
=
"回复"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/reply/{examTitleId}"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/reply/{examTitleId}"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
reply
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
public
PicaResponse
reply
(
@PathVariable
(
"examTitleId"
)
Integer
examTitleId
,
@RequestBody
String
content
,
@RequestBody
String
content
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
sysCode
)
{
@RequestHeader
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/nextReply"
);
if
(
token
==
null
)
{
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
picaResponse
.
setData
(
""
);
return
picaResponse
;
}
PicaUser
user
=
fetchPicaUser
();
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
content
=
jsonObject
.
get
(
"content"
).
toString
();
content
=
jsonObject
.
get
(
"content"
).
toString
();
}
catch
(
Exception
e
)
{
return
analysisService
.
reply
(
fetchPicaUser
(),
sysCode
,
examTitleId
,
content
,
false
);
logger
.
info
(
"parse error: "
+
content
);
}
/**
* 如果判断检测的数据中有垃圾 直接返回
*/
PicaResponse
response
=
antiSpamService
.
processString
(
user
.
getId
(),
sysCode
,
content
,
false
);
if
(!
response
.
getCode
().
equals
(
PicaResultCode
.
SUCCESS
.
code
()))
{
response
.
setData
(
""
);
return
response
;
}
/**
* 插入数据库
*/
try
{
analysisService
.
insertReply
(
examTitleId
,
content
,
user
.
getId
());
t
.
setStatus
(
Transaction
.
SUCCESS
);
t
.
complete
();
}
catch
(
Exception
e
)
{
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
t
.
complete
();
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
INTERFACE_INVOKE_EXCEPTION
);
picaResponse
.
setData
(
""
);
return
picaResponse
;
}
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
picaResponse
.
setMessage
(
"发布成功"
);
return
picaResponse
;
}
Integer
getReplyStatus
(
Integer
analysisId
,
Integer
examTitleId
,
Integer
userId
)
{
Doctor
doctor
=
doctorService
.
getDoctorById
(
userId
);
if
(
doctor
!=
null
)
{
CHCAnalysis
analysis
=
analysisService
.
getAnalysisById
(
analysisId
);
if
(
analysis
.
getType
()
==
1
)
{
/**
* CHC 获取考试前两百名
*/
if
(
rankingListService
.
isRankingInTop200
(
doctor
.
getId
()))
{
return
analysisService
.
getReplyStatus
(
examTitleId
,
userId
);
}
}
else
if
(
analysis
.
getType
()
==
2
)
{
/**
* 如果为认证 不可见
*/
if
(!(
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_3
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_6
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_7
)
))
{
return
0
;
}
/**
* PSA 职务职称主任/副主任 院长/副院长 科长/副科长 管理人数100以上
*/
if
(
doctorService
.
isAuth
(
doctor
.
getId
()))
{
return
analysisService
.
getReplyStatus
(
examTitleId
,
userId
);
}
}
}
return
0
;
}
}
@ApiOperation
(
value
=
"获取某一轮的题目V2"
,
response
=
PicaResponse
.
class
)
@ApiOperation
(
value
=
"获取某一轮的题目V2"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/roundDetail/v2/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/roundDetail/v2/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
RoundExamTitleV2Dto
>
getRoundDetailV2
(
@PathVariable
(
value
=
"roundId"
)
Integer
roundId
)
{
public
PicaResponse
<
RoundExamTitleV2Dto
>
getRoundDetailV2
(
@PathVariable
(
value
=
"roundId"
)
Integer
roundId
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/roundDetail/v2/"
);
logger
.
info
(
"roundDetail: roundId"
+
roundId
);
PicaResponse
.
Builder
<
RoundExamTitleV2Dto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
RoundExamTitleV2Dto
>
builder
=
new
PicaResponse
.
Builder
<>();
builder
.
setData
(
analysisService
.
getRoundDetailV2
(
roundId
));
try
{
RoundExamTitleV2Dto
roundExamTitleV2Dto
=
new
RoundExamTitleV2Dto
();
if
(
roundId
>
0
)
{
/**
* 有rounfid传入时设置roundList为空
*/
roundExamTitleV2Dto
.
setRoundList
(
new
ArrayList
<>());
}
else
{
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
/**
* 获取list中最后一个的roundId
*/
if
(
roundDtoList
.
size
()
>
0
)
{
roundId
=
roundDtoList
.
get
(
roundDtoList
.
size
()
-
1
).
getRoundId
();
}
roundExamTitleV2Dto
.
setRoundList
(
roundDtoList
);
}
RoundExamTitleDto
roundExamTitleDto
=
analysisService
.
getRoundExamTitleDtoById
(
roundId
);
/**
* 转换格式
*/
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
outFormat
=
new
SimpleDateFormat
(
"yyyy-M-d"
);
roundExamTitleV2Dto
.
setAnalysisId
(
roundExamTitleDto
.
getAnalysisId
());
roundExamTitleV2Dto
.
setRoundId
(
roundExamTitleDto
.
getRoundId
());
roundExamTitleV2Dto
.
setStartTime
(
outFormat
.
format
(
sdf
.
parse
(
roundExamTitleDto
.
getStartTime
())));
roundExamTitleV2Dto
.
setEndTime
(
outFormat
.
format
(
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
())));
roundExamTitleV2Dto
.
setTotalCount
(
roundExamTitleDto
.
getTotalCount
());
roundExamTitleV2Dto
.
setPublished
(
roundExamTitleDto
.
getPublished
());
if
((
new
Date
()).
getTime
()
>
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
()).
getTime
())
{
roundExamTitleV2Dto
.
setRemainingTime
(
""
);
roundExamTitleV2Dto
.
setIsFinished
(
1
);
roundExamTitleV2Dto
.
setElectedStarCount
(
analysisService
.
getElectedStarCountByRoundId
(
roundId
));
Integer
doctorId
=
analysisService
.
getElectedDoctorIdByRoundId
(
roundId
);
roundExamTitleV2Dto
.
setElectedDoctor
(
doctorId
!=
null
?
doctorService
.
getDoctorDtoById
(
doctorId
)
:
new
DoctorDto
()
);
}
else
{
roundExamTitleV2Dto
.
setRemainingTime
(
DateUtils
.
remainingTime
(
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
())));
roundExamTitleV2Dto
.
setIsFinished
(
0
);
roundExamTitleV2Dto
.
setElectedDoctor
(
new
DoctorDto
());
}
List
<
ExamTitleDto
>
examTitleDtoList
=
analysisService
.
getExamTitleListByRoundId
(
roundId
);
roundExamTitleV2Dto
.
setExamTitleList
(
examTitleDtoList
);
builder
.
setData
(
roundExamTitleV2Dto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"getRoundDetailV2"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
t
.
complete
();
return
builder
.
build
();
return
builder
.
build
();
}
}
@LoginPermission
@LoginPermission
@ApiOperation
(
value
=
"我的赞"
,
response
=
PicaResponse
.
class
)
@ApiOperation
(
value
=
"我的赞"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
{
"/myStar/{roundId}"
,
"/myStar/"
},
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
{
"/myStar/{roundId}"
,
"/myStar/"
},
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
MyStarDto
>
myStar
(
@PathVariable
(
value
=
"roundId"
,
required
=
false
)
Integer
roundId
,
public
PicaResponse
<
MyStarDto
>
myStar
(
@PathVariable
(
value
=
"roundId"
,
required
=
false
)
Integer
roundId
)
{
@RequestHeader
(
required
=
false
)
String
token
)
{
Transaction
t
=
Cat
.
newTransaction
(
"Link"
,
"/roundDetail/v2/"
);
PicaUser
user
=
fetchPicaUser
();
if
(
roundId
!=
null
)
{
logger
.
info
(
"myStar: roundId="
+
roundId
.
toString
()
+
" token="
+
token
);
}
PicaResponse
.
Builder
<
MyStarDto
>
builder
=
new
PicaResponse
.
Builder
<>();
PicaResponse
.
Builder
<
MyStarDto
>
builder
=
new
PicaResponse
.
Builder
<>();
try
{
builder
.
setData
(
analysisService
.
myStar
(
fetchPicaUser
(),
Optional
.
ofNullable
(
roundId
)));
MyStarDto
myStarDto
=
new
MyStarDto
();
myStarDto
.
setDoctor
(
doctorService
.
getDoctorDtoById
(
user
.
getId
()));
myStarDto
.
setRoundList
(
new
ArrayList
<>());
if
(
roundId
==
null
)
{
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
roundId
=
roundDtoList
.
get
(
0
).
getRoundId
();
myStarDto
.
setRoundList
(
roundDtoList
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy.M.d"
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
roundId
);
myStarDto
.
setStartTime
(
sdf
.
format
(
analysisRound
.
getStartTime
()));
myStarDto
.
setEndTime
(
sdf
.
format
(
analysisRound
.
getEndTime
()));
myStarDto
.
setRemainingTime
(
DateUtils
.
remainingTime
(
analysisRound
.
getEndTime
()));
/**
* 设置结束状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
myStarDto
.
setIsFinished
(
1
);
/**
* 设置我是否当选
*/
Integer
electedDoctorId
=
analysisService
.
getElectedDoctorIdByRoundId
(
roundId
);
myStarDto
.
setIsElected
(
electedDoctorId
.
intValue
()
==
user
.
getId
().
intValue
()
?
1
:
0
);
}
else
{
myStarDto
.
setIsFinished
(
0
);
myStarDto
.
setIsElected
(
0
);
}
/**
* 设置我的得赞数
*/
myStarDto
.
setMyStarCount
(
analysisService
.
getStarCountByRoundIdAndDoctorId
(
roundId
,
user
.
getId
()));
/**
* 我的解析得赞记录
*/
myStarDto
.
setMyExamTitleList
(
analysisService
.
getMyStarRecordByRoundIdAndDoctorId
(
roundId
,
user
.
getId
()));
builder
.
setData
(
myStarDto
);
t
.
setStatus
(
Transaction
.
SUCCESS
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"myStar"
,
e
);
t
.
setStatus
(
e
);
Cat
.
logError
(
e
);
}
t
.
complete
();
return
builder
.
build
();
return
builder
.
build
();
}
}
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AntiSpamController.java
浏览文件 @
e4fec645
...
@@ -9,8 +9,8 @@ import com.pica.cloud.foundation.utils.controller.BaseController;
...
@@ -9,8 +9,8 @@ import com.pica.cloud.foundation.utils.controller.BaseController;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.online.exam.analysis.common.util.ReturnUtil
;
import
com.pica.cloud.online.exam.analysis.common.util.ReturnUtil
;
import
com.pica.cloud.online.exam.analysis.server.service.AntiSpamService
;
import
com.pica.cloud.online.exam.analysis.server.service.AntiSpamService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -36,31 +36,16 @@ public class AntiSpamController extends BaseController {
...
@@ -36,31 +36,16 @@ public class AntiSpamController extends BaseController {
@RequestHeader
String
sysCode
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
token
)
{
@RequestHeader
String
token
)
{
PicaUser
user
=
fetchPicaUser
();
PicaUser
user
=
fetchPicaUser
();
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
Pair
<
String
,
Integer
>
params
;
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
StringBuilder
sbContent
=
new
StringBuilder
();
/**
* type:0 不检测广告 其他: 检测广告, 默认不检测
*/
Integer
type
=
0
;
try
{
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
params
=
parseContentAndType
(
content
);
sbContent
.
append
(
jsonObject
.
get
(
"content"
).
toString
());
type
=
(
jsonObject
.
get
(
"type"
)
!=
null
?
Integer
.
parseInt
(
jsonObject
.
get
(
"type"
).
toString
())
:
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
}
return
antiSpamService
.
processString
(
user
.
getId
(),
sysCode
,
params
.
getLeft
(),
params
.
getRight
()
!=
0
);
return
antiSpamService
.
processString
(
user
.
getId
(),
sysCode
,
sbContent
.
toString
(),
type
!=
0
);
}
}
@LoginPermission
@ApiOperation
(
value
=
"内容检测"
,
response
=
PicaResponse
.
class
)
@ApiOperation
(
value
=
"内容检测"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/text/v1"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/text/v1"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
processTextV1
(
@RequestBody
String
content
,
public
PicaResponse
processTextV1
(
@RequestBody
String
content
,
...
@@ -69,35 +54,21 @@ public class AntiSpamController extends BaseController {
...
@@ -69,35 +54,21 @@ public class AntiSpamController extends BaseController {
return
processText
(
content
,
sysCode
,
token
);
return
processText
(
content
,
sysCode
,
token
);
}
}
@LoginPermission
@ApiOperation
(
value
=
"内容检测"
,
response
=
PicaResponse
.
class
)
@ApiOperation
(
value
=
"内容检测"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/text/v2"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
@RequestMapping
(
value
=
"/text/v2"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
processTextV2
(
@RequestBody
String
content
,
public
PicaResponse
processTextV2
(
@RequestBody
String
content
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
token
)
{
@RequestHeader
String
token
)
{
PicaUser
user
=
fetchPicaUser
();
PicaUser
user
=
fetchPicaUser
();
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
Pair
<
String
,
Integer
>
params
;
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
StringBuilder
sbContent
=
new
StringBuilder
();
/**
* type:0 不检测广告 其他: 检测广告, 默认不检测
*/
Integer
type
=
0
;
try
{
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
params
=
parseContentAndType
(
content
);
sbContent
.
append
(
jsonObject
.
get
(
"content"
).
toString
());
type
=
(
jsonObject
.
get
(
"type"
)
!=
null
?
Integer
.
parseInt
(
jsonObject
.
get
(
"type"
).
toString
())
:
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PARAM_IS_INVALID
);
}
}
return
antiSpamService
.
processStringV2
(
return
antiSpamService
.
processStringV2
(
user
.
getId
(),
sysCode
,
params
.
getLeft
(),
params
.
getRight
()
!=
0
);
user
.
getId
(),
sysCode
,
sbContent
.
toString
(),
type
!=
0
);
}
}
@LoginPermission
@LoginPermission
...
@@ -106,14 +77,7 @@ public class AntiSpamController extends BaseController {
...
@@ -106,14 +77,7 @@ public class AntiSpamController extends BaseController {
public
PicaResponse
processImage
(
@RequestBody
String
content
,
public
PicaResponse
processImage
(
@RequestBody
String
content
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
sysCode
,
@RequestHeader
String
token
)
{
@RequestHeader
String
token
)
{
if
(
token
==
null
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
}
PicaUser
user
=
fetchPicaUser
();
PicaUser
user
=
fetchPicaUser
();
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
StringBuilder
sbContent
=
new
StringBuilder
();
StringBuilder
sbContent
=
new
StringBuilder
();
try
{
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
...
@@ -128,4 +92,11 @@ public class AntiSpamController extends BaseController {
...
@@ -128,4 +92,11 @@ public class AntiSpamController extends BaseController {
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
}
public
Pair
<
String
,
Integer
>
parseContentAndType
(
String
content
)
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
return
Pair
.
of
(
jsonObject
.
get
(
"content"
).
toString
(),
jsonObject
.
get
(
"type"
)
!=
null
?
Integer
.
parseInt
(
jsonObject
.
get
(
"type"
).
toString
())
:
0
);
}
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/CHCAnalysisService.java
浏览文件 @
e4fec645
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
service
;
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
service
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.server.entity.AnalysisRound
;
import
com.pica.cloud.online.exam.analysis.server.entity.AnalysisRound
;
import
com.pica.cloud.online.exam.analysis.server.entity.AnalysisRoundExamTitle
;
import
com.pica.cloud.online.exam.analysis.server.entity.AnalysisRoundExamTitle
;
import
com.pica.cloud.online.exam.analysis.server.entity.CHCAnalysis
;
import
com.pica.cloud.online.exam.analysis.server.entity.CHCAnalysis
;
import
com.pica.cloud.online.exam.analysis.server.entity.Reply
;
import
com.pica.cloud.online.exam.analysis.server.entity.Reply
;
import
io.swagger.models.auth.In
;
import
org.omg.CORBA.INTERNAL
;
import
org.omg.CORBA.INTERNAL
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
/**
/**
* @author wuminghao
* @author wuminghao
...
@@ -17,198 +20,109 @@ import java.util.List;
...
@@ -17,198 +20,109 @@ import java.util.List;
public
interface
CHCAnalysisService
{
public
interface
CHCAnalysisService
{
/**
/**
* 获取消息详情
* 获取CHC活动详情
* @param analysisId
* @param analysisId 活动id
* @param user
* @return
* @return
*/
*/
CHCAnalysisDto
getActivityDetail
(
Integer
analysisId
,
PicaUser
user
);
CHCAnalysisDto
get
CHC
ActivityDetail
(
Integer
analysisId
,
PicaUser
user
);
/**
/**
*
根据活动id获取
活动详情
*
获取PSA
活动详情
* @param analysisId
* @param analysisId
活动id
* @return
* @return
*/
*/
CHCAnalysis
getAnalysisById
(
Integer
analysisId
);
CHCAnalysis
Dto
getPSAActivityDetail
(
Integer
analysisId
);
/**
/**
*
根据活动id获取活动
详情
*
获取轮
详情
* @param
analysisI
d
* @param
roundId 轮i
d
* @return
* @return
*/
*/
CHCAnalysisDto
getCHCAnalysisDtoById
(
Integer
analysis
Id
);
RoundExamTitleDto
getRoundDetail
(
Integer
round
Id
);
/**
/**
* 根据活动id获取活动详情
* 获取轮详情V2
* @param analysisId
* @return
*/
CHCAnalysisDto
getPSAAnalysisDtoById
(
Integer
analysisId
);
/**
* 根据活动id获取活动的轮数
* @param analysisId
* @return
*/
List
<
AnalysisRoundDto
>
getRoundListByAnalysisId
(
Integer
analysisId
);
/**
* 根据轮的id获取信息
* @param roundId
* @return
*/
RoundExamTitleDto
getRoundExamTitleDtoById
(
Integer
roundId
);
/**
* 根据轮的id获取信息
* @param roundId
* @return
*/
AnalysisRound
getRoundInfoById
(
Integer
roundId
);
/**
* 根据轮的id获取题目信息
* @param roundId
* @param roundId
* @return
* @return
*/
*/
List
<
ExamTitleDto
>
getExamTitleListByRoundId
(
Integer
roundId
);
RoundExamTitleV2Dto
getRoundDetailV2
(
Integer
roundId
);
/**
* 获取当前的活动-轮-题目关联表
* @param analysisRoundExamTitleId
* @return
*/
AnalysisRoundExamTitle
getAnanlysisRoundExamTitleById
(
Integer
analysisRoundExamTitleId
);
/**
* 获取考题信息
* @param analysisRoundExamTitleId
* @return
*/
ExamTitleDto
getExamTitleDtoById
(
Integer
analysisRoundExamTitleId
);
/**
/**
* 获取当前题目的下一题目
* 获取题目的回复列表
* @param roundId 当前轮的id
* @param analysisRoundExamTitleId 当前题目的id
* @return 下一题目的id
*/
ExamTitleDto
getNextExamTitleDtoById
(
Integer
roundId
,
Integer
analysisRoundExamTitleId
);
/**
* 根据题目id获取回复信息
* @param analysisRoundExamTitleId
* @param userId
* @return
*/
List
<
ReplyDto
>
getReplyListDtoByExamTitleId
(
Integer
analysisRoundExamTitleId
,
Integer
userId
);
/**
* 根据id获取reply
* @param replyId
* @return
*/
Reply
getReplyById
(
Integer
replyId
);
/**
* 根据id获取下一条reply
* @param replyId
* @return
*/
Reply
getNextReplyById
(
Integer
replyId
);
/**
* 根据reply获取replydto
* @param reply
* @param userId
* @return
*/
ReplyDto
getReplyDtoByReply
(
Reply
reply
,
Integer
userId
);
/**
* 插入点赞记录
* @param analysisId
* @param roundId
* @param examTitleId
* @param examTitleId
* @param
replyId
* @param
user
* @return
* @return
*/
*/
Integer
insertStarRecord
(
Integer
analysisId
,
Integer
roundId
,
Integer
examTitleId
,
Integer
replyId
,
Integer
userId
);
ExamTitleReplyDto
getReplyListByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
);
/**
/**
* 取消点赞记录
* 获取下一题的回复列表
* @param replyId
* @param userId
* @return
*/
Integer
removeStarRecord
(
Integer
replyId
,
Integer
userId
);
/**
* 增加解析
* @param examTitleId
* @param content
* @param userId
* @return
*/
Integer
insertReply
(
Integer
examTitleId
,
String
content
,
Integer
userId
);
/**
* 获取我的评论状态
* @param examTitleId
* @param examTitleId
* @param user
Id
* @param user
* @return
* @return
*/
*/
Integer
getReplyStatus
(
Integer
examTitleId
,
Integer
userId
);
ExamTitleReplyDto
getNextReplyListByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
);
/**
/**
* 获取
我的评论
详情
* 获取
回复的
详情
* @param
examTitleI
d
* @param
replyId 回复i
d
* @param user
Id
* @param user
用户
* @return
* @return
*/
*/
Reply
getReplyByExamTitleId
(
Integer
examTitleId
,
Integer
userId
);
ExamTitleReplyDetailDto
getReplyDetailByReplyId
(
Integer
replyId
,
PicaUser
user
);
/**
/**
* 根据考试id获取评论列表
* 获取下一回复的详情
* @param examTitleId
* @param replyId
* @param user
* @return
* @return
*/
*/
List
<
Reply
>
getReplyList
(
Integer
examTitleId
);
ExamTitleReplyDetailDto
getNextReplyDetailByReplyId
(
Integer
replyId
,
PicaUser
user
);
/**
/**
* 获取所有的历史轮详情
* 获取回复的详情
* @param analysisId
* @param examTitleId 题目id
* @param user 用户
* @return
* @return
*/
*/
List
<
AnalysisRoundDto
>
getCHCHistoryRound
(
Integer
analysisId
);
ExamTitleReplyDetailDto
getReplyDetailByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
);
/**
/**
* 获取某一轮的最多得票数
* 点赞
* @param roundId
* @param user 用户
* @param analysisId 活动id
* @param roundId 轮id
* @param examTitleId 题目id
* @param replyId 回复id
* @return
* @return
*/
*/
Integer
getElectedStarCountByRoundId
(
Integer
round
Id
);
PicaResponse
starReply
(
PicaUser
user
,
Integer
analysisId
,
Integer
roundId
,
Integer
examTitleId
,
Integer
reply
Id
);
/**
/**
* 获取被选中的医生id
* 解析/回复某一个题目
* @param roundId
* @param user 用户
* @param sysCode
* @param examTitleId 题目
* @param content 内容
* @param isAdFilterOpen 广告检测
* @return
* @return
*/
*/
Integer
getElectedDoctorIdByRoundId
(
Integer
roundId
);
PicaResponse
reply
(
PicaUser
user
,
String
sysCode
,
Integer
examTitleId
,
String
content
,
Boolean
isAdFilterOpen
);
/**
/**
*
根据医生id和轮id获取得赞数
*
获取我的赞
* @param
roundId
* @param
user 用户
* @param
doctorI
d
* @param
roundId 某轮的i
d
* @return
* @return
*/
*/
Integer
getStarCountByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctor
Id
);
MyStarDto
myStar
(
PicaUser
user
,
Optional
<
Integer
>
round
Id
);
/**
/**
*
根据医生id和轮id获取得赞记录
*
取消点赞
* @param r
oundI
d
* @param r
eplyId 活动i
d
* @param
doctorId
* @param
user 用户
* @return
* @return
*/
*/
List
<
UserExamTitleDto
>
getMyStarRecordByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
);
Integer
removeStarRecord
(
Integer
replyId
,
PicaUser
user
);
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/CHCAnalysisServiceImpl.java
浏览文件 @
e4fec645
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
service
.
impl
;
package
com
.
pica
.
cloud
.
online
.
exam
.
analysis
.
server
.
service
.
impl
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.online.exam.analysis.common.constants.CommonConstants
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.common.dto.*
;
import
com.pica.cloud.online.exam.analysis.common.util.ReturnUtil
;
import
com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.online.exam.analysis.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.online.exam.analysis.server.entity.*
;
import
com.pica.cloud.online.exam.analysis.server.entity.*
;
import
com.pica.cloud.online.exam.analysis.server.mapper.*
;
import
com.pica.cloud.online.exam.analysis.server.mapper.*
;
import
com.pica.cloud.online.exam.analysis.server.service.AntiSpamService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCAnalysisService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCRankingListService
;
import
com.pica.cloud.online.exam.analysis.server.service.CHCRankingListService
;
import
com.pica.cloud.online.exam.analysis.server.service.DoctorService
;
import
com.pica.cloud.online.exam.analysis.server.utils.DateUtils
;
import
com.pica.cloud.online.exam.analysis.server.utils.DateUtils
;
import
net.bytebuddy.asm.Advice
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -53,6 +60,18 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -53,6 +60,18 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
@Autowired
@Autowired
private
CHCRankingListService
chcRankingListService
;
private
CHCRankingListService
chcRankingListService
;
@Autowired
private
DoctorService
doctorService
;
@Autowired
private
AntiSpamService
antiSpamService
;
static
final
byte
ANALYSIS_TYPE_CHC
=
1
;
static
final
byte
ANALYSIS_TYPE_PSA
=
2
;
static
final
int
CHC_ANALYSIS_ID
=
1
;
static
final
int
PSA_ANALYSIS_ID
=
2
;
/**
/**
* chc 活动详情
* chc 活动详情
* @param analysisId
* @param analysisId
...
@@ -60,7 +79,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -60,7 +79,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
* @return
* @return
*/
*/
@Override
@Override
public
CHCAnalysisDto
getActivityDetail
(
Integer
analysisId
,
PicaUser
user
)
{
public
CHCAnalysisDto
get
CHC
ActivityDetail
(
Integer
analysisId
,
PicaUser
user
)
{
CHCAnalysisDto
analysisDto
=
this
.
getCHCAnalysisDtoById
(
analysisId
);
CHCAnalysisDto
analysisDto
=
this
.
getCHCAnalysisDtoById
(
analysisId
);
if
(
chcRankingListService
.
isRankingInTop200
(
user
!=
null
?
user
.
getId
()
:
0
))
{
if
(
chcRankingListService
.
isRankingInTop200
(
user
!=
null
?
user
.
getId
()
:
0
))
{
analysisDto
.
setIsJoinIn
(
1
);
analysisDto
.
setIsJoinIn
(
1
);
...
@@ -69,6 +88,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -69,6 +88,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
}
}
List
<
AnalysisRoundDto
>
roundList
=
this
.
getRoundListByAnalysisId
(
analysisId
);
List
<
AnalysisRoundDto
>
roundList
=
this
.
getRoundListByAnalysisId
(
analysisId
);
if
(
analysisId
==
CHC_ANALYSIS_ID
)
{
/**
/**
* chc活动固定返回两轮, 将第一轮设置为所有
* chc活动固定返回两轮, 将第一轮设置为所有
*/
*/
...
@@ -83,19 +103,325 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -83,19 +103,325 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
analysisRoundDto
.
setRoundId
(-
2
);
analysisRoundDto
.
setRoundId
(-
2
);
roundList
.
add
(
analysisRoundDto
);
roundList
.
add
(
analysisRoundDto
);
}
}
}
analysisDto
.
setRoundList
(
roundList
);
analysisDto
.
setRoundList
(
roundList
);
return
analysisDto
;
return
analysisDto
;
}
}
@Override
@Override
public
CHCAnalysis
getAnalysisById
(
Integer
analysisId
)
{
public
CHCAnalysisDto
getPSAActivityDetail
(
Integer
analysisId
)
{
return
analysisMapper
.
selectByPrimaryKey
(
analysisId
);
CHCAnalysisDto
analysisDto
=
getPSAAnalysisDtoById
(
analysisId
);
List
<
AnalysisRoundDto
>
roundList
=
getRoundListByAnalysisId
(
analysisId
);
analysisDto
.
setRoundList
(
roundList
);
return
analysisDto
;
}
@Override
public
RoundExamTitleDto
getRoundDetail
(
Integer
roundId
)
{
RoundExamTitleDto
roundExamTitleDto
=
getRoundExamTitleDtoById
(
roundId
);
List
<
ExamTitleDto
>
examTitleDtoList
=
getExamTitleListByRoundId
(
roundId
);
roundExamTitleDto
.
setExamTitleList
(
examTitleDtoList
);
return
roundExamTitleDto
;
}
@Override
public
RoundExamTitleV2Dto
getRoundDetailV2
(
Integer
roundId
)
{
RoundExamTitleV2Dto
roundExamTitleV2Dto
=
new
RoundExamTitleV2Dto
();
/**
* 有rounfid传入时设置roundList为空
*/
if
(
roundId
>
0
)
{
roundExamTitleV2Dto
.
setRoundList
(
new
ArrayList
<>());
}
else
{
List
<
AnalysisRoundDto
>
roundDtoList
=
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
/**
* 获取list中最后一个的roundId
*/
if
(
roundDtoList
.
size
()
>
0
)
{
roundId
=
roundDtoList
.
get
(
roundDtoList
.
size
()
-
1
).
getRoundId
();
}
roundExamTitleV2Dto
.
setRoundList
(
roundDtoList
);
}
RoundExamTitleDto
roundExamTitleDto
=
getRoundExamTitleDtoById
(
roundId
);
try
{
/**
* 转换格式
*/
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
outFormat
=
new
SimpleDateFormat
(
"yyyy-M-d"
);
roundExamTitleV2Dto
.
setAnalysisId
(
roundExamTitleDto
.
getAnalysisId
());
roundExamTitleV2Dto
.
setRoundId
(
roundExamTitleDto
.
getRoundId
());
roundExamTitleV2Dto
.
setStartTime
(
outFormat
.
format
(
sdf
.
parse
(
roundExamTitleDto
.
getStartTime
())));
roundExamTitleV2Dto
.
setEndTime
(
outFormat
.
format
(
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
())));
roundExamTitleV2Dto
.
setTotalCount
(
roundExamTitleDto
.
getTotalCount
());
roundExamTitleV2Dto
.
setPublished
(
roundExamTitleDto
.
getPublished
());
if
((
new
Date
()).
getTime
()
>
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
()).
getTime
())
{
roundExamTitleV2Dto
.
setRemainingTime
(
""
);
roundExamTitleV2Dto
.
setIsFinished
(
1
);
roundExamTitleV2Dto
.
setElectedStarCount
(
getElectedStarCountByRoundId
(
roundId
));
Integer
doctorId
=
getElectedDoctorIdByRoundId
(
roundId
);
roundExamTitleV2Dto
.
setElectedDoctor
(
doctorId
!=
null
?
doctorService
.
getDoctorDtoById
(
doctorId
)
:
new
DoctorDto
());
}
else
{
roundExamTitleV2Dto
.
setRemainingTime
(
DateUtils
.
remainingTime
(
sdf
.
parse
(
roundExamTitleDto
.
getEndTime
())));
roundExamTitleV2Dto
.
setIsFinished
(
0
);
roundExamTitleV2Dto
.
setElectedDoctor
(
new
DoctorDto
());
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"getRoundDetailV2: "
,
e
);
}
List
<
ExamTitleDto
>
examTitleDtoList
=
getExamTitleListByRoundId
(
roundId
);
roundExamTitleV2Dto
.
setExamTitleList
(
examTitleDtoList
);
return
roundExamTitleV2Dto
;
}
@Override
public
ExamTitleReplyDto
getReplyListByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
)
{
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
examTitleId
);
CHCAnalysis
analysis
=
analysisMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getAnalysisId
());
ExamTitleReplyDto
examTitleReplyDto
=
new
ExamTitleReplyDto
();
ExamTitleDto
examTitleDto
=
getExamTitleDtoById
(
examTitleId
);
List
<
ReplyDto
>
replyDtoList
=
getReplyListDtoByExamTitleId
(
examTitleId
,
user
!=
null
?
user
.
getId
()
:
0
);
/**
* 如果是PSA 删除回复的时间显示
*/
if
(
analysis
.
getType
()
==
ANALYSIS_TYPE_PSA
)
{
replyDtoList
.
forEach
(
replyDto
->
replyDto
.
setReplayTime
(
""
));
}
examTitleReplyDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDto
.
setReplyList
(
replyDtoList
);
examTitleReplyDto
.
setType
(
analysis
.
getType
().
intValue
());
AnalysisRound
analysisRound
=
analysisRoundMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
/**
* 设置回复状态
*/
examTitleReplyDto
.
setReplyStatus
(
0
);
if
((
new
Date
()).
getTime
()
<
analysisRound
.
getEndTime
().
getTime
())
{
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDto
.
setReplyStatus
(
getReplyStatus
(
analysis
,
examTitleId
,
user
.
getId
()));
}
}
return
examTitleReplyDto
;
}
@Override
public
ExamTitleReplyDto
getNextReplyListByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
)
{
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
examTitleId
);
ExamTitleDto
examTitleDto
=
getNextExamTitleDtoById
(
analysisRoundExamTitle
.
getRoundId
(),
examTitleId
);
return
getReplyListByExamTitleId
(
examTitleDto
.
getExamTitleId
(),
user
);
}
@Override
public
ExamTitleReplyDetailDto
getReplyDetailByReplyId
(
Integer
replyId
,
PicaUser
user
)
{
ExamTitleReplyDetailDto
examTitleReplyDetailDto
=
new
ExamTitleReplyDetailDto
();
Reply
reply
=
replyMapper
.
selectByPrimaryKey
(
replyId
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
reply
.
getAnalysisRoundExamTitleId
());
ExamTitleDto
examTitleDto
=
getExamTitleDtoById
(
reply
.
getAnalysisRoundExamTitleId
());
ReplyDto
replyDto
=
getReplyDtoByReply
(
reply
,
user
!=
null
?
user
.
getId
()
:
0
);
CHCAnalysis
analysis
=
analysisMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDetailDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDetailDto
.
setReply
(
replyDto
);
examTitleReplyDetailDto
.
setType
(
analysis
.
getType
().
intValue
());
AnalysisRound
analysisRound
=
analysisRoundMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDetailDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
/**
* 设置回复状态
*/
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
((
new
Date
()).
getTime
()
<
analysisRound
.
getEndTime
().
getTime
())
{
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDetailDto
.
setReplyStatus
(
getReplyStatus
(
analysis
,
reply
.
getAnalysisRoundExamTitleId
(),
user
.
getId
()));
}
}
return
examTitleReplyDetailDto
;
}
@Override
public
ExamTitleReplyDetailDto
getNextReplyDetailByReplyId
(
Integer
replyId
,
PicaUser
user
)
{
Reply
reply
=
getNextReplyById
(
replyId
);
return
getReplyDetailByReplyId
(
reply
.
getId
(),
user
);
}
}
@Override
@Override
public
CHCAnalysisDto
getCHCAnalysisDtoById
(
Integer
analysisId
)
{
public
ExamTitleReplyDetailDto
getReplyDetailByExamTitleId
(
Integer
examTitleId
,
PicaUser
user
)
{
ExamTitleReplyDetailDto
examTitleReplyDetailDto
=
new
ExamTitleReplyDetailDto
();
Reply
reply
=
getReplyByExamTitleId
(
examTitleId
,
user
!=
null
?
user
.
getId
()
:
0
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
examTitleId
);
ExamTitleDto
examTitleDto
=
getExamTitleDtoById
(
examTitleId
);
ReplyDto
replyDto
=
new
ReplyDto
();
if
(
null
!=
reply
)
{
replyDto
=
getReplyDtoByReply
(
reply
,
user
!=
null
?
user
.
getId
()
:
0
);
}
else
{
replyDto
.
setContent
(
""
);
}
examTitleReplyDetailDto
.
setAnalysisId
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setRoundId
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDetailDto
.
setExamTitle
(
examTitleDto
);
examTitleReplyDetailDto
.
setReply
(
replyDto
);
AnalysisRound
analysisRound
=
analysisRoundMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getRoundId
());
examTitleReplyDetailDto
.
setPublished
(
analysisRound
.
getIsPublished
()
?
1
:
0
);
CHCAnalysis
analysis
=
analysisMapper
.
selectByPrimaryKey
(
analysisRoundExamTitle
.
getAnalysisId
());
examTitleReplyDetailDto
.
setType
(
analysis
.
getType
().
intValue
());
/**
* 设置回复状态
*/
examTitleReplyDetailDto
.
setReplyStatus
(
0
);
if
((
new
Date
()).
getTime
()
<
analysisRound
.
getEndTime
().
getTime
())
{
if
(
user
!=
null
&&
user
.
getId
()
!=
0
)
{
examTitleReplyDetailDto
.
setReplyStatus
(
getReplyStatus
(
analysis
,
reply
.
getAnalysisRoundExamTitleId
(),
user
.
getId
()));
}
}
return
examTitleReplyDetailDto
;
}
@Override
public
PicaResponse
starReply
(
PicaUser
user
,
Integer
analysisId
,
Integer
roundId
,
Integer
examTitleId
,
Integer
replyId
)
{
Doctor
doctor
=
doctorService
.
getDoctorById
(
user
.
getId
());
/**
* 未认证用户直接返回
*/
if
(!(
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_3
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_6
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_7
)
))
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
INTERFACE_FORBID_VISIT
);
}
AnalysisRound
analysisRound
=
analysisRoundMapper
.
selectByPrimaryKey
(
roundId
);
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
return
ReturnUtil
.
getPicaResponse
(
"500002"
,
"本期活动已结束"
);
}
/**
* 已经点过赞
*/
if
(
0
!=
insertStarRecord
(
analysisId
,
roundId
,
examTitleId
,
replyId
,
user
.
getId
()))
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
DATA_ALREADY_EXISTED
);
}
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
}
@Override
public
PicaResponse
reply
(
PicaUser
user
,
String
sysCode
,
Integer
examTitleId
,
String
content
,
Boolean
isAdFilterOpen
)
{
/**
* 如果判断检测的数据中有垃圾 直接返回
*/
PicaResponse
response
=
antiSpamService
.
processString
(
user
.
getId
(),
sysCode
,
content
,
false
);
if
(!
response
.
getCode
().
equals
(
PicaResultCode
.
SUCCESS
.
code
()))
{
response
.
setData
(
""
);
return
response
;
}
insertReply
(
examTitleId
,
content
,
user
.
getId
());
PicaResponse
picaResponse
=
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SUCCESS
);
picaResponse
.
setMessage
(
"发布成功"
);
return
picaResponse
;
}
@Override
public
MyStarDto
myStar
(
PicaUser
user
,
Optional
<
Integer
>
roundId
)
{
MyStarDto
myStarDto
=
new
MyStarDto
();
myStarDto
.
setDoctor
(
doctorService
.
getDoctorDtoById
(
user
.
getId
()));
myStarDto
.
setRoundList
(
new
ArrayList
<>());
if
(!
roundId
.
isPresent
())
{
List
<
AnalysisRoundDto
>
roundDtoList
=
getCHCHistoryRound
(
CHC_ANALYSIS_ID
);
roundId
=
Optional
.
of
(
roundDtoList
.
get
(
0
).
getRoundId
());
myStarDto
.
setRoundList
(
roundDtoList
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy.M.d"
);
AnalysisRound
analysisRound
=
analysisRoundMapper
.
selectByPrimaryKey
(
roundId
.
get
());
myStarDto
.
setStartTime
(
sdf
.
format
(
analysisRound
.
getStartTime
()));
myStarDto
.
setEndTime
(
sdf
.
format
(
analysisRound
.
getEndTime
()));
myStarDto
.
setRemainingTime
(
DateUtils
.
remainingTime
(
analysisRound
.
getEndTime
()));
/**
* 设置结束状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
myStarDto
.
setIsFinished
(
1
);
/**
* 设置我是否当选
*/
Integer
electedDoctorId
=
getElectedDoctorIdByRoundId
(
roundId
.
get
());
myStarDto
.
setIsElected
(
electedDoctorId
.
intValue
()
==
user
.
getId
().
intValue
()
?
1
:
0
);
}
else
{
myStarDto
.
setIsFinished
(
0
);
myStarDto
.
setIsElected
(
0
);
}
/**
* 设置我的得赞数
*/
myStarDto
.
setMyStarCount
(
getStarCountByRoundIdAndDoctorId
(
roundId
.
get
(),
user
.
getId
()));
/**
* 我的解析得赞记录
*/
myStarDto
.
setMyExamTitleList
(
getMyStarRecordByRoundIdAndDoctorId
(
roundId
.
get
(),
user
.
getId
()));
return
myStarDto
;
}
@Override
public
Integer
removeStarRecord
(
Integer
replyId
,
PicaUser
user
)
{
/**
* 1. 判断是否存在点赞记录
*/
StarRecord
starRecord
=
new
StarRecord
();
starRecord
.
setReplyId
(
replyId
);
starRecord
.
setCreatedId
(
user
.
getId
());
if
(
starRecordMapper
.
selectStarCountByRecord
(
starRecord
)
==
0
)
{
return
-
1
;
}
/**
* 2. 删除点赞记录
*/
StarRecord
record
=
starRecordMapper
.
selectBySelective
(
starRecord
);
record
.
setModifiedId
(
user
.
getId
());
record
.
setModifiedTime
(
new
Date
());
record
.
setIsDeleted
(
true
);
starRecordMapper
.
updateByPrimaryKeySelective
(
record
);
/**
* 3. 修改点赞数
*/
Reply
reply
=
replyMapper
.
selectByPrimaryKey
(
replyId
);
reply
.
setStarCount
(
reply
.
getStarCount
()
-
1
);
replyMapper
.
updateByPrimaryKey
(
reply
);
return
0
;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
private
CHCAnalysisDto
getCHCAnalysisDtoById
(
Integer
analysisId
)
{
CHCAnalysis
analysis
=
analysisMapper
.
selectCHCByPrimaryKey
(
analysisId
);
CHCAnalysis
analysis
=
analysisMapper
.
selectCHCByPrimaryKey
(
analysisId
);
if
(
null
==
analysis
)
{
if
(
null
==
analysis
)
{
...
@@ -120,8 +446,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -120,8 +446,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
analysisDto
;
return
analysisDto
;
}
}
@Override
private
CHCAnalysisDto
getPSAAnalysisDtoById
(
Integer
analysisId
)
{
public
CHCAnalysisDto
getPSAAnalysisDtoById
(
Integer
analysisId
)
{
CHCAnalysis
analysis
=
analysisMapper
.
selectPSAByPrimaryKey
(
analysisId
);
CHCAnalysis
analysis
=
analysisMapper
.
selectPSAByPrimaryKey
(
analysisId
);
if
(
null
==
analysis
)
{
if
(
null
==
analysis
)
{
return
null
;
return
null
;
...
@@ -145,8 +470,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -145,8 +470,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
analysisDto
;
return
analysisDto
;
}
}
@Override
private
List
<
AnalysisRoundDto
>
getRoundListByAnalysisId
(
Integer
analysisId
)
{
public
List
<
AnalysisRoundDto
>
getRoundListByAnalysisId
(
Integer
analysisId
)
{
List
<
AnalysisRound
>
roundList
=
new
ArrayList
<
AnalysisRound
>();
List
<
AnalysisRound
>
roundList
=
new
ArrayList
<
AnalysisRound
>();
CHCAnalysis
analysis
=
analysisMapper
.
selectByPrimaryKey
(
analysisId
);
CHCAnalysis
analysis
=
analysisMapper
.
selectByPrimaryKey
(
analysisId
);
...
@@ -187,8 +511,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -187,8 +511,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
roundDtoList
;
return
roundDtoList
;
}
}
@Override
private
RoundExamTitleDto
getRoundExamTitleDtoById
(
Integer
roundId
)
{
public
RoundExamTitleDto
getRoundExamTitleDtoById
(
Integer
roundId
)
{
AnalysisRound
round
=
analysisRoundMapper
.
selectByPrimaryKey
(
roundId
);
AnalysisRound
round
=
analysisRoundMapper
.
selectByPrimaryKey
(
roundId
);
if
(
null
==
round
)
{
if
(
null
==
round
)
{
...
@@ -216,13 +539,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -216,13 +539,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
roundExamTitleDto
;
return
roundExamTitleDto
;
}
}
@Override
private
List
<
ExamTitleDto
>
getExamTitleListByRoundId
(
Integer
roundId
)
{
public
AnalysisRound
getRoundInfoById
(
Integer
roundId
)
{
return
analysisRoundMapper
.
selectByPrimaryKey
(
roundId
);
}
@Override
public
List
<
ExamTitleDto
>
getExamTitleListByRoundId
(
Integer
roundId
)
{
List
<
AnalysisRoundExamTitle
>
roundExamTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
roundExamTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
if
(
null
==
roundExamTitleList
)
{
if
(
null
==
roundExamTitleList
)
{
...
@@ -238,13 +555,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -238,13 +555,6 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
ExamTitleDtoList
;
return
ExamTitleDtoList
;
}
}
@Override
public
AnalysisRoundExamTitle
getAnanlysisRoundExamTitleById
(
Integer
analysisRoundExamTitleId
)
{
return
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
analysisRoundExamTitleId
);
}
@Override
public
ExamTitleDto
getExamTitleDtoById
(
Integer
analysisRoundExamTitleId
)
{
public
ExamTitleDto
getExamTitleDtoById
(
Integer
analysisRoundExamTitleId
)
{
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
analysisRoundExamTitleId
);
AnalysisRoundExamTitle
analysisRoundExamTitle
=
analysisRoundExamTitleMapper
.
selectByPrimaryKey
(
analysisRoundExamTitleId
);
...
@@ -292,8 +602,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -292,8 +602,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
examTitleDto
;
return
examTitleDto
;
}
}
@Override
private
List
<
ReplyDto
>
getReplyListDtoByExamTitleId
(
Integer
analysisRoundExamTitleId
,
Integer
userId
)
{
public
List
<
ReplyDto
>
getReplyListDtoByExamTitleId
(
Integer
analysisRoundExamTitleId
,
Integer
userId
)
{
List
<
Reply
>
replyList
=
getReplyList
(
analysisRoundExamTitleId
);
List
<
Reply
>
replyList
=
getReplyList
(
analysisRoundExamTitleId
);
List
<
ReplyDto
>
replyDtoList
=
new
ArrayList
<>();
List
<
ReplyDto
>
replyDtoList
=
new
ArrayList
<>();
...
@@ -312,13 +621,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -312,13 +621,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyDtoList
;
return
replyDtoList
;
}
}
@Override
private
Reply
getNextReplyById
(
Integer
replyId
)
{
public
Reply
getReplyById
(
Integer
replyId
)
{
return
replyMapper
.
selectByPrimaryKey
(
replyId
);
}
@Override
public
Reply
getNextReplyById
(
Integer
replyId
)
{
Reply
reply
=
replyMapper
.
selectByPrimaryKey
(
replyId
);
Reply
reply
=
replyMapper
.
selectByPrimaryKey
(
replyId
);
/**
/**
...
@@ -342,8 +645,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -342,8 +645,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyList
.
get
(
idx
);
return
replyList
.
get
(
idx
);
}
}
@Override
private
ReplyDto
getReplyDtoByReply
(
Reply
reply
,
Integer
userId
)
{
public
ReplyDto
getReplyDtoByReply
(
Reply
reply
,
Integer
userId
)
{
ReplyDto
replyDto
=
new
ReplyDto
();
ReplyDto
replyDto
=
new
ReplyDto
();
Doctor
doctor
=
doctorMapper
.
selectByPrimaryKey
(
reply
.
getUserId
());
Doctor
doctor
=
doctorMapper
.
selectByPrimaryKey
(
reply
.
getUserId
());
...
@@ -375,8 +677,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -375,8 +677,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyDto
;
return
replyDto
;
}
}
@Override
private
Integer
insertStarRecord
(
Integer
analysisId
,
Integer
roundId
,
Integer
examTitleId
,
Integer
replyId
,
Integer
userId
)
{
public
Integer
insertStarRecord
(
Integer
analysisId
,
Integer
roundId
,
Integer
examTitleId
,
Integer
replyId
,
Integer
userId
)
{
StarRecord
starRecord
=
new
StarRecord
();
StarRecord
starRecord
=
new
StarRecord
();
starRecord
.
setAnalysisId
(
analysisId
);
starRecord
.
setAnalysisId
(
analysisId
);
...
@@ -412,41 +713,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -412,41 +713,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
0
;
return
0
;
}
}
@Override
private
ExamTitleDto
getNextExamTitleDtoById
(
Integer
roundId
,
Integer
analysisRoundExamTitleId
)
{
public
Integer
removeStarRecord
(
Integer
replyId
,
Integer
userId
)
{
/**
* 1. 判断是否存在点赞记录
*/
StarRecord
starRecord
=
new
StarRecord
();
starRecord
.
setReplyId
(
replyId
);
starRecord
.
setCreatedId
(
userId
);
if
(
starRecordMapper
.
selectStarCountByRecord
(
starRecord
)
==
0
)
{
return
-
1
;
}
/**
* 2. 删除点赞记录
*/
StarRecord
record
=
starRecordMapper
.
selectBySelective
(
starRecord
);
record
.
setModifiedId
(
userId
);
record
.
setModifiedTime
(
new
Date
());
record
.
setIsDeleted
(
true
);
starRecordMapper
.
updateByPrimaryKeySelective
(
record
);
/**
* 3. 修改点赞数
*/
Reply
reply
=
replyMapper
.
selectByPrimaryKey
(
replyId
);
reply
.
setStarCount
(
reply
.
getStarCount
()
-
1
);
replyMapper
.
updateByPrimaryKey
(
reply
);
return
0
;
}
@Override
public
ExamTitleDto
getNextExamTitleDtoById
(
Integer
roundId
,
Integer
analysisRoundExamTitleId
)
{
List
<
AnalysisRoundExamTitle
>
roundExamTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
roundExamTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
Integer
examTitleCount
=
roundExamTitleList
.
size
();
Integer
examTitleCount
=
roundExamTitleList
.
size
();
...
@@ -463,8 +730,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -463,8 +730,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
this
.
getExamTitleDtoById
(
roundExamTitleList
.
get
(
idx
).
getId
());
return
this
.
getExamTitleDtoById
(
roundExamTitleList
.
get
(
idx
).
getId
());
}
}
@Override
private
Integer
insertReply
(
Integer
examTitleId
,
String
content
,
Integer
userId
)
{
public
Integer
insertReply
(
Integer
examTitleId
,
String
content
,
Integer
userId
)
{
/**
/**
* 找到我是否已经回复过,如果回复过就编辑,没有就新建
* 找到我是否已经回复过,如果回复过就编辑,没有就新建
*/
*/
...
@@ -497,8 +763,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -497,8 +763,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
}
}
}
}
@Override
private
Integer
getReplyStatus
(
Integer
examTitleId
,
Integer
userId
)
{
public
Integer
getReplyStatus
(
Integer
examTitleId
,
Integer
userId
)
{
/**
/**
* 用户不存在
* 用户不存在
*/
*/
...
@@ -526,16 +791,14 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -526,16 +791,14 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
2
;
return
2
;
}
}
@Override
private
Reply
getReplyByExamTitleId
(
Integer
examTitleId
,
Integer
userId
)
{
public
Reply
getReplyByExamTitleId
(
Integer
examTitleId
,
Integer
userId
)
{
Reply
reply
=
new
Reply
();
Reply
reply
=
new
Reply
();
reply
.
setAnalysisRoundExamTitleId
(
examTitleId
);
reply
.
setAnalysisRoundExamTitleId
(
examTitleId
);
reply
.
setUserId
(
userId
);
reply
.
setUserId
(
userId
);
return
replyMapper
.
selectReplyByRecord
(
reply
);
return
replyMapper
.
selectReplyByRecord
(
reply
);
}
}
@Override
private
List
<
Reply
>
getReplyList
(
Integer
examTitleId
)
{
public
List
<
Reply
>
getReplyList
(
Integer
examTitleId
)
{
Integer
replyCount
=
replyMapper
.
selectReplyCountByAnalysisRoundExamTitleId
(
examTitleId
);
Integer
replyCount
=
replyMapper
.
selectReplyCountByAnalysisRoundExamTitleId
(
examTitleId
);
/**
/**
...
@@ -562,8 +825,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -562,8 +825,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyListOther
;
return
replyListOther
;
}
}
@Override
private
List
<
AnalysisRoundDto
>
getCHCHistoryRound
(
Integer
analysisId
)
{
public
List
<
AnalysisRoundDto
>
getCHCHistoryRound
(
Integer
analysisId
)
{
List
<
AnalysisRound
>
roundList
=
new
ArrayList
<>();
List
<
AnalysisRound
>
roundList
=
new
ArrayList
<>();
/**
/**
...
@@ -600,8 +862,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -600,8 +862,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
roundDtoList
;
return
roundDtoList
;
}
}
@Override
private
Integer
getElectedStarCountByRoundId
(
Integer
roundId
)
{
public
Integer
getElectedStarCountByRoundId
(
Integer
roundId
)
{
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
...
@@ -610,8 +871,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -610,8 +871,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyMapper
.
selectElectedStarCountByExamTitleIdList
(
examTitleIdList
);
return
replyMapper
.
selectElectedStarCountByExamTitleIdList
(
examTitleIdList
);
}
}
@Override
private
Integer
getElectedDoctorIdByRoundId
(
Integer
roundId
)
{
public
Integer
getElectedDoctorIdByRoundId
(
Integer
roundId
)
{
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
...
@@ -620,8 +880,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -620,8 +880,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyMapper
.
selectElectedDoctorIdByExamTitleIdList
(
examTitleIdList
);
return
replyMapper
.
selectElectedDoctorIdByExamTitleIdList
(
examTitleIdList
);
}
}
@Override
private
Integer
getStarCountByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
public
Integer
getStarCountByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
Map
param
=
new
HashMap
<>();
Map
param
=
new
HashMap
<>();
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
...
@@ -633,8 +892,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -633,8 +892,7 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
replyMapper
.
selectStarCountByParam
(
param
);
return
replyMapper
.
selectStarCountByParam
(
param
);
}
}
@Override
private
List
<
UserExamTitleDto
>
getMyStarRecordByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
public
List
<
UserExamTitleDto
>
getMyStarRecordByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
Map
param
=
new
HashMap
<>();
Map
param
=
new
HashMap
<>();
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
...
@@ -669,4 +927,37 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
...
@@ -669,4 +927,37 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
return
userExamTitleDtos
;
return
userExamTitleDtos
;
}
}
Integer
getReplyStatus
(
CHCAnalysis
analysis
,
Integer
examTitleId
,
Integer
userId
)
{
Doctor
doctor
=
doctorService
.
getDoctorById
(
userId
);
if
(
doctor
!=
null
)
{
if
(
analysis
.
getType
()
==
ANALYSIS_TYPE_CHC
)
{
/**
* CHC 获取考试前两百名
*/
if
(
chcRankingListService
.
isRankingInTop200
(
doctor
.
getId
()))
{
return
getReplyStatus
(
examTitleId
,
userId
);
}
}
else
if
(
analysis
.
getType
()
==
ANALYSIS_TYPE_PSA
)
{
/**
* 如果未认证 不可见
*/
if
(!(
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_3
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_6
)
||
doctor
.
getStatus
().
equals
(
CommonConstants
.
DOCTOR_STATUS_7
)
))
{
return
0
;
}
/**
* PSA 职务职称主任/副主任 院长/副院长 科长/副科长 管理人数100以上
*/
if
(
doctorService
.
isAuth
(
doctor
.
getId
()))
{
return
getReplyStatus
(
examTitleId
,
userId
);
}
}
}
return
0
;
}
}
}
server/src/main/resources/bootstrap-dev.properties
浏览文件 @
e4fec645
server.port
=
10902
server.port
=
10902
server.context-path
=
/analysis
server.context-path
=
/analysis
spring.application.name
=
${server.port}-pica-cloud-analysis
spring.application.name
=
${server.port}-pica-cloud-analysis
_local
#config server settings
#config server settings
spring.cloud.config.name
=
com.pica.cloud.online.exam
spring.cloud.config.name
=
com.pica.cloud.online.exam
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录