Commit 7e4ed296 by “Kongxiangkun”

投票列表增加分页

parent 9440f548
...@@ -104,8 +104,8 @@ public interface ResearchQuestionClient { ...@@ -104,8 +104,8 @@ public interface ResearchQuestionClient {
*/ */
@GetMapping("/researchQuestion/getVoteResult") @GetMapping("/researchQuestion/getVoteResult")
VoteRankingVo getVoteResult(@RequestParam("researchId") Long researchId, 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 { ...@@ -193,8 +193,8 @@ public class TrResearchQuestionController {
*/ */
@GetMapping("/getVoteResult") @GetMapping("/getVoteResult")
VoteRankingVo getVoteResult(@RequestParam("researchId") Long researchId, 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); return researchQuestionService.getVoteResult(researchId, pageNo, pageSize);
} }
......
...@@ -99,14 +99,23 @@ public interface TrResearchQuestionMapper extends BaseMapper<TrResearchQuestion> ...@@ -99,14 +99,23 @@ public interface TrResearchQuestionMapper extends BaseMapper<TrResearchQuestion>
* @param siteId * @param siteId
* @param researchId * @param researchId
* @param accountId * @param accountId
* @param isTop
* @return * @return
*/ */
VoteRankingVo getVoteResult(@Param("companyId") Long companyId, @Param("siteId") Long siteId, 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("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 id
* @param researchId * @param researchId
......
...@@ -185,16 +185,12 @@ ...@@ -185,16 +185,12 @@
</update> </update>
<select id="getVoteResult" resultMap="getVoteResultMap"> <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 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 ,IFNULL(myanswer.answerState,0) AS answerState
</if>
,r.vote_num ,r.vote_num
FROM tr_research_question a FROM tr_research_question a
INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0 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 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 research r ON a.research_id=r.id AND r.deleted=0
<if test="isTop == null or isTop == false" >
LEFT JOIN( LEFT JOIN(
SELECT myb.question_id,COUNT(myb.question_id) AS answerState SELECT myb.question_id,COUNT(myb.question_id) AS answerState
FROM tr_research_answer mya FROM tr_research_answer mya
...@@ -203,18 +199,21 @@ ...@@ -203,18 +199,21 @@
WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1 WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1
GROUP BY myb.question_id GROUP BY myb.question_id
) myanswer ON b.question_id=myanswer.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 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 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) ,IFNULL(myanswer.answerState,0)
</if> ORDER BY a.no limit #{pageStart},#{pageEnd}
<if test="isTop != null and isTop == true" > </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) ORDER BY COUNT(c.id) DESC,MIN(c.create_time)
</if>
<if test="isTop != null and isTop == false" >
ORDER BY a.no
</if>
</select> </select>
</mapper> </mapper>
...@@ -1161,7 +1161,7 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio ...@@ -1161,7 +1161,7 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio
Long companyId = context.getCompanyId(); Long companyId = context.getCompanyId();
Long siteId = context.getSiteId(); Long siteId = context.getSiteId();
LOG.info("投票列表入参, companyId:{}, siteId:{}, researchId:{}, start:{}, range:{}", companyId, siteId, researchId, (pageNo - 1) * pageSize, pageSize); 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)); LOG.info("投票列表返回, voteRankingVo:{}", JSONUtil.toJsonStr(voteRankingVo));
if(voteRankingVo != null){ if(voteRankingVo != null){
Integer finish = trResearchAnswerMapper.getResearchAnsweFinish(context.getAccountId(), researchId); Integer finish = trResearchAnswerMapper.getResearchAnsweFinish(context.getAccountId(), researchId);
...@@ -1182,19 +1182,16 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio ...@@ -1182,19 +1182,16 @@ public class TrResearchQuestionServiceImpl extends ServiceImpl<TrResearchQuestio
@Override @Override
public VoteRankingVo getVoteTop(Long researchId) { public VoteRankingVo getVoteTop(Long researchId) {
Integer pageNo = 1;
Integer pageSize = Integer.MAX_VALUE;
RequestContext context = ContextHolder.get(); RequestContext context = ContextHolder.get();
Long companyId = context.getCompanyId(); Long companyId = context.getCompanyId();
Long siteId = context.getSiteId(); 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())){ if(result != null && !CollectionUtils.isEmpty(result.getRankingList())){
int no = 1; int no = 1;
for(VoteRankingListVo item : result.getRankingList()){ for(VoteRankingListVo item : result.getRankingList()){
item.setNo(no++); item.setNo(no++);
} }
} }
return result; 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