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
......
...@@ -184,37 +184,36 @@ ...@@ -184,37 +184,36 @@
</foreach> </foreach>
</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 ,r.vote_num
</if> FROM tr_research_question a
,r.vote_num INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0
FROM tr_research_question a LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id
INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0 LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0
LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id LEFT JOIN(
LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0 SELECT myb.question_id,COUNT(myb.question_id) AS answerState
FROM tr_research_answer mya
<if test="isTop == null or isTop == false" > INNER JOIN tr_research_answer_question myb ON myb.answer_id=mya.id AND myb.deleted=0
LEFT JOIN( INNER JOIN tr_research_answer_question_result myc ON myc.answer_question_id=myb.id AND myc.option_id IS NOT NULL
SELECT myb.question_id,COUNT(myb.question_id) AS answerState WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1
FROM tr_research_answer mya GROUP BY myb.question_id
INNER JOIN tr_research_answer_question myb ON myb.answer_id=mya.id AND myb.deleted=0 ) myanswer ON b.question_id=myanswer.question_id
INNER JOIN tr_research_answer_question_result myc ON myc.answer_question_id=myb.id AND myc.option_id IS NOT NULL WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0
WHERE mya.research_id=#{researchId} AND mya.account_id=#{accountId} AND mya.finish=1 GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num
GROUP BY myb.question_id ,IFNULL(myanswer.answerState,0)
) myanswer ON b.question_id=myanswer.question_id ORDER BY a.no limit #{pageStart},#{pageEnd}
</if> </select>
WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0 <select id="getVoteTop" resultMap="getVoteResultMap">
GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num 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" > ,r.vote_num
,IFNULL(myanswer.answerState,0) FROM tr_research_question a
</if> INNER JOIN tr_research_question_option b ON a.id=b.question_id AND b.deleted=0
<if test="isTop != null and isTop == true" > LEFT JOIN tr_research_answer_question_result c ON c.option_id=b.id
ORDER BY COUNT(c.id) DESC,MIN(c.create_time) LEFT JOIN research r ON a.research_id=r.id AND r.deleted=0
</if> WHERE a.research_id=#{researchId} AND a.company_id=#{companyId} AND a.site_id=#{siteId} AND a.deleted=0
<if test="isTop != null and isTop == false" > GROUP BY r.id,r.name,a.id,a.no,a.content_appendix_url,b.content, a.keywords,r.vote_num
ORDER BY a.no ORDER BY COUNT(c.id) DESC,MIN(c.create_time)
</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