Commit 7e4ed296 by “Kongxiangkun”

投票列表增加分页

parent 9440f548
......@@ -104,8 +104,8 @@ public interface ResearchQuestionClient {
*/
@GetMapping("/researchQuestion/getVoteResult")
VoteRankingVo getVoteResult(@RequestParam("researchId") Long researchId,
@RequestParam(value = "pageSize", required = false) Integer pageSize,
@RequestParam(value = "pageNo", required = false) Integer pageNo);
@RequestParam(value = "pageNo", required = false) Integer pageNo,
@RequestParam(value = "pageSize", required = false) Integer pageSize);
/**
* 获取投票排行榜
......
......@@ -193,8 +193,8 @@ public class TrResearchQuestionController {
*/
@GetMapping("/getVoteResult")
VoteRankingVo getVoteResult(@RequestParam("researchId") Long researchId,
@RequestParam(value = "pageSize", required = false) Integer pageSize,
@RequestParam(value = "pageNo", required = false) Integer pageNo) {
@RequestParam(value = "pageNo", required = false) Integer pageNo,
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
return researchQuestionService.getVoteResult(researchId, pageNo, pageSize);
}
......
......@@ -99,14 +99,23 @@ public interface TrResearchQuestionMapper extends BaseMapper<TrResearchQuestion>
* @param siteId
* @param researchId
* @param accountId
* @param isTop
* @return
*/
VoteRankingVo getVoteResult(@Param("companyId") Long companyId, @Param("siteId") Long siteId,
@Param("researchId") Long researchId, @Param("accountId") Long accountId, @Param("isTop") boolean isTop,
@Param("researchId") Long researchId, @Param("accountId") Long accountId,
@Param("pageStart") Integer pageStart,@Param("pageEnd") Integer pageEnd);
/**
* 投票排行榜
* @param companyId
* @param siteId
* @param researchId
* @return
*/
VoteRankingVo getVoteTop(@Param("companyId") Long companyId, @Param("siteId") Long siteId,
@Param("researchId") Long researchId);
/**
* 刪除投票中的指定問題
* @param id
* @param researchId
......
......@@ -184,37 +184,36 @@
</foreach>
</update>
<select id="getVoteResult" resultMap="getVoteResultMap">
SELECT r.id,r.name,a.id AS questionId,a.no,a.content_appendix_url,b.content, a.keywords,COUNT(c.id) AS voteCount
<if test="isTop == null or isTop == false" >
,IFNULL(myanswer.answerState,0) AS answerState
</if>
,r.vote_num
FROM tr_research_question a
INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0
LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id
LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0
<if test="isTop == null or isTop == false" >
LEFT JOIN(
SELECT myb.question_id,COUNT(myb.question_id) AS answerState
FROM tr_research_answer mya
INNER JOIN tr_research_answer_question myb ON myb.answer_id=mya.id AND myb.deleted=0
INNER JOIN tr_research_answer_question_result myc ON myc.answer_question_id=myb.id AND myc.option_id IS NOT NULL
WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1
GROUP BY myb.question_id
) myanswer ON b.question_id=myanswer.question_id
</if>
WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0
GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num
<if test="isTop == null or isTop == false" >
,IFNULL(myanswer.answerState,0)
</if>
<if test="isTop != null and isTop == true" >
ORDER BY COUNT(c.id) DESC,MIN(c.create_time)
</if>
<if test="isTop != null and isTop == false" >
ORDER BY a.no
</if>
SELECT r.id,r.name,a.id AS questionId,a.no,a.content_appendix_url,b.content, a.keywords,COUNT(c.id) AS voteCount
,IFNULL(myanswer.answerState,0) AS answerState
,r.vote_num
FROM tr_research_question a
INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0
LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id
LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0
LEFT JOIN(
SELECT myb.question_id,COUNT(myb.question_id) AS answerState
FROM tr_research_answer mya
INNER JOIN tr_research_answer_question myb ON myb.answer_id=mya.id AND myb.deleted=0
INNER JOIN tr_research_answer_question_result myc ON myc.answer_question_id=myb.id AND myc.option_id IS NOT NULL
WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1
GROUP BY myb.question_id
) myanswer ON b.question_id=myanswer.question_id
WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0
GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num
,IFNULL(myanswer.answerState,0)
ORDER BY a.no limit #{pageStart},#{pageEnd}
</select>
<select id="getVoteTop" resultMap="getVoteResultMap">
SELECT r.id,r.name,a.id AS questionId,a.no,a.content_appendix_url,b.content, a.keywords,COUNT(c.id) AS voteCount
,r.vote_num
FROM tr_research_question a
INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0
LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id
LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0
WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0
GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num
ORDER BY COUNT(c.id) DESC,MIN(c.create_time)
</select>
</mapper>
......@@ -1161,7 +1161,7 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio
Long companyId = context.getCompanyId();
Long siteId = context.getSiteId();
LOG.info("投票列表入参, companyId:{}, siteId:{}, researchId:{}, start:{}, range:{}", companyId, siteId, researchId, (pageNo - 1) * pageSize, pageSize);
VoteRankingVo voteRankingVo = researchQuestionMapper.getVoteResult(companyId, siteId, researchId, context.getAccountId(), false, (pageNo - 1) * pageSize , pageSize);
VoteRankingVo voteRankingVo = researchQuestionMapper.getVoteResult(companyId, siteId, researchId, context.getAccountId(),(pageNo - 1) * pageSize , pageSize);
LOG.info("投票列表返回, voteRankingVo:{}", JSONUtil.toJsonStr(voteRankingVo));
if(voteRankingVo != null){
Integer finish = trResearchAnswerMapper.getResearchAnsweFinish(context.getAccountId(), researchId);
......@@ -1182,19 +1182,16 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio
@Override
public VoteRankingVo getVoteTop(Long researchId) {
Integer pageNo = 1;
Integer pageSize = Integer.MAX_VALUE;
RequestContext context = ContextHolder.get();
Long companyId = context.getCompanyId();
Long siteId = context.getSiteId();
VoteRankingVo result = researchQuestionMapper.getVoteResult(companyId, siteId, researchId, context.getAccountId(), true, pageNo, pageSize);
VoteRankingVo result = researchQuestionMapper.getVoteTop(companyId, siteId, researchId);
if(result != null && !CollectionUtils.isEmpty(result.getRankingList())){
int no = 1;
for(VoteRankingListVo item : result.getRankingList()){
item.setNo(no++);
}
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment