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
提交
d12203cb
提交
d12203cb
编写于
9月 05, 2018
作者:
minghao.wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: 我的赞
上级
4d524770
变更
6
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
171 行增加
和
4 行删除
+171
-4
pom.xml
server/pom.xml
+1
-1
AnalysisController.java
...e/exam/analysis/server/controller/AnalysisController.java
+64
-0
ReplyMapper.java
...cloud/online/exam/analysis/server/mapper/ReplyMapper.java
+15
-0
CHCAnalysisService.java
...line/exam/analysis/server/service/CHCAnalysisService.java
+17
-0
CHCAnalysisServiceImpl.java
.../analysis/server/service/impl/CHCAnalysisServiceImpl.java
+49
-3
ReplyMapper.xml
server/src/main/resources/mybatis/ReplyMapper.xml
+25
-0
未找到文件。
server/pom.xml
浏览文件 @
d12203cb
...
...
@@ -138,7 +138,7 @@
<dependency>
<groupId>
com.pica.cloud.online.exam
</groupId>
<artifactId>
pica-cloud-analysis-common
</artifactId>
<version>
1.0.
4
</version>
<version>
1.0.
6
</version>
<scope>
compile
</scope>
</dependency>
...
...
server/src/main/java/com/pica/cloud/online/exam/analysis/server/controller/AnalysisController.java
浏览文件 @
d12203cb
...
...
@@ -19,6 +19,7 @@ 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.omg.CORBA.INTERNAL
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -625,4 +626,67 @@ public class AnalysisController {
return
builder
.
build
();
}
@ApiOperation
(
value
=
"我的赞"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/myStar/{roundId}"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
MyStarDto
>
myStar
(
@PathVariable
(
value
=
"roundId"
,
required
=
false
)
Integer
roundId
,
@RequestHeader
(
required
=
false
)
String
token
)
{
if
(
token
==
null
)
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
SYSTEM_NO_TOKEN
);
}
PICAUser
user
=
CommonUtils
.
getUserByToken
(
redisClient
,
token
);
if
(
user
==
null
||
user
.
getId
().
intValue
()
==
0
)
{
System
.
out
.
println
(
"myStar: user == null, token="
+
token
);
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
LOGIN_FAILE
);
}
if
(!
rankingListService
.
isRankingInTop200
(
user
.
getId
()))
{
return
ReturnUtil
.
getPicaResponse
(
PicaResultCode
.
PERMISSION_NO_ACCESS
);
}
System
.
out
.
println
(
"myStar: roundId="
+
roundId
.
toString
()
+
" token="
+
token
);
PicaResponse
.
Builder
<
MyStarDto
>
builder
=
new
PicaResponse
.
Builder
<>();
MyStarDto
myStarDto
=
new
MyStarDto
();
myStarDto
.
setDoctor
(
doctorService
.
getDoctorDtoById
(
user
.
getId
()));
myStarDto
.
setRoundList
(
new
ArrayList
<>());
if
(
roundId
==
null
)
{
List
<
AnalysisRoundDto
>
roundDtoList
=
analysisService
.
getCHCHistoryRound
();
roundId
=
roundDtoList
.
get
(
0
).
getRoundId
();
myStarDto
.
setRoundList
(
roundDtoList
);
}
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM:dd HH:mm:ss"
);
AnalysisRound
analysisRound
=
analysisService
.
getRoundInfoById
(
roundId
);
myStarDto
.
setStartTime
(
sdf
.
format
(
analysisRound
.
getStartTime
()));
myStarDto
.
setEndTime
(
sdf
.
format
(
analysisRound
.
getEndTime
()));
/**
* 设置结束状态
*/
if
((
new
Date
()).
getTime
()
>
analysisRound
.
getEndTime
().
getTime
())
{
myStarDto
.
setIsFinished
(
1
);
}
else
{
myStarDto
.
setIsFinished
(
0
);
}
/**
* 设置我的得赞数
*/
myStarDto
.
setMyStarCount
(
analysisService
.
getStarCountByRoundIdAndDoctorId
(
roundId
,
user
.
getId
()));
/**
* 设置我是否当选
*/
Integer
electedDoctorId
=
analysisService
.
getElectedDoctorIdByRoundId
(
roundId
);
myStarDto
.
setIsElected
(
electedDoctorId
.
intValue
()
==
user
.
getId
().
intValue
()
?
1
:
0
);
/**
* 我的解析得赞记录
*/
myStarDto
.
setMyExamTitleList
(
analysisService
.
getMyStarRecordByRoundIdAndDoctorId
(
roundId
,
user
.
getId
()));
builder
.
setData
(
myStarDto
);
return
builder
.
build
();
}
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/mapper/ReplyMapper.java
浏览文件 @
d12203cb
...
...
@@ -3,6 +3,7 @@ package com.pica.cloud.online.exam.analysis.server.mapper;
import
com.pica.cloud.online.exam.analysis.server.entity.Reply
;
import
java.util.List
;
import
java.util.Map
;
public
interface
ReplyMapper
{
int
deleteByPrimaryKey
(
Integer
id
);
...
...
@@ -52,4 +53,18 @@ public interface ReplyMapper {
* @return
*/
Integer
selectElectedDoctorIdByExamTitleIdList
(
List
<
Integer
>
examTitleIds
);
/**
* 获取某人某轮的获赞数
* @param param
* @return
*/
Integer
selectStarCountByParam
(
Map
param
);
/**
* 获取某人某轮的获赞记录
* @param param
* @return
*/
List
<
Reply
>
selectStarRecordByParam
(
Map
param
);
}
\ No newline at end of file
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/CHCAnalysisService.java
浏览文件 @
d12203cb
...
...
@@ -5,6 +5,7 @@ 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.CHCAnalysis
;
import
com.pica.cloud.online.exam.analysis.server.entity.Reply
;
import
org.omg.CORBA.INTERNAL
;
import
java.util.List
;
...
...
@@ -184,4 +185,20 @@ public interface CHCAnalysisService {
* @return
*/
Integer
getElectedDoctorIdByRoundId
(
Integer
roundId
);
/**
* 根据医生id和轮id获取得赞数
* @param roundId
* @param doctorId
* @return
*/
Integer
getStarCountByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
);
/**
* 根据医生id和轮id获取得赞记录
* @param roundId
* @param doctorId
* @return
*/
List
<
UserExamTitleDto
>
getMyStarRecordByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
);
}
server/src/main/java/com/pica/cloud/online/exam/analysis/server/service/impl/CHCAnalysisServiceImpl.java
浏览文件 @
d12203cb
...
...
@@ -13,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
/**
* @author wuminghao
...
...
@@ -571,4 +569,52 @@ public class CHCAnalysisServiceImpl implements CHCAnalysisService {
}
return
replyMapper
.
selectElectedDoctorIdByExamTitleIdList
(
examTitleIdList
);
}
@Override
public
Integer
getStarCountByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
Map
param
=
new
HashMap
<>();
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
examTitleIdList
.
add
(
examTitle
.
getId
());
}
param
.
put
(
"examTitleList"
,
examTitleIdList
);
param
.
put
(
"doctorId"
,
doctorId
);
return
replyMapper
.
selectStarCountByParam
(
param
);
}
@Override
public
List
<
UserExamTitleDto
>
getMyStarRecordByRoundIdAndDoctorId
(
Integer
roundId
,
Integer
doctorId
)
{
Map
param
=
new
HashMap
<>();
List
<
AnalysisRoundExamTitle
>
examTitleList
=
analysisRoundExamTitleMapper
.
selectExamTitleListByRoundId
(
roundId
);
List
<
Integer
>
examTitleIdList
=
new
ArrayList
<>();
for
(
AnalysisRoundExamTitle
examTitle
:
examTitleList
)
{
examTitleIdList
.
add
(
examTitle
.
getId
());
}
param
.
put
(
"examTitleList"
,
examTitleIdList
);
param
.
put
(
"doctorId"
,
doctorId
);
List
<
Reply
>
replyList
=
replyMapper
.
selectStarRecordByParam
(
param
);
List
<
UserExamTitleDto
>
userExamTitleDtos
=
new
ArrayList
<>();
for
(
int
idx
=
0
;
idx
<
examTitleIdList
.
size
();
++
idx
)
{
UserExamTitleDto
userExamTitleDto
=
new
UserExamTitleDto
();
userExamTitleDto
.
setExamTitleId
(
examTitleIdList
.
get
(
idx
));
userExamTitleDto
.
setSeqNo
(
idx
+
1
);
boolean
isReplied
=
false
;
Integer
starCount
=
0
;
for
(
Reply
reply
:
replyList
)
{
if
(
reply
.
getAnalysisRoundExamTitleId
().
intValue
()
==
examTitleIdList
.
get
(
idx
).
intValue
())
{
isReplied
=
true
;
starCount
=
reply
.
getStarCount
();
break
;
}
}
userExamTitleDto
.
setIsReplied
(
isReplied
?
1
:
0
);
userExamTitleDto
.
setStarCount
(
starCount
);
}
return
userExamTitleDtos
;
}
}
server/src/main/resources/mybatis/ReplyMapper.xml
浏览文件 @
d12203cb
...
...
@@ -110,6 +110,31 @@
limit 1
</select>
<select
id=
"selectStarCountByParam"
resultType=
"java.lang.Integer"
>
select
sum(star_count)
from p_reply
where analysis_round_exam_title_id in
<foreach
item=
"item"
index=
"index"
collection=
"examTitleList"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
and is_deleted = 0
and user_id = #{doctorId,jdbcType=INTEGER}
</select>
<select
id=
"selectStarRecordByParam"
resultType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from p_reply
where analysis_round_exam_title_id in
<foreach
item=
"item"
index=
"index"
collection=
"examTitleList"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
and is_deleted = 0
and user_id = #{doctorId,jdbcType=INTEGER}
order by analysis_round_exam_title_id
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from p_reply
where id = #{id,jdbcType=INTEGER}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录